Will the compiler-generated default constructor be public?

前端 未结 7 1285
小鲜肉
小鲜肉 2021-01-12 05:36

When I write a class Widget.java

public class Widget {
    int data;
    String name;
}

will the compiler-generated constructo

7条回答
  •  有刺的猬
    2021-01-12 05:55

    If your class is public then the default constructor would be public so in your case, Since the Widget class is public its default constructor supplied by the compiler would also be public. See this

提交回复
热议问题