Will the compiler-generated default constructor be public?

前端 未结 7 1294
小鲜肉
小鲜肉 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:52

    It depends on your class visibility.The compiler uses the class visibility and generates a no-arg default constructor with the same visibility

提交回复
热议问题