class access

来源:互联网 发布:unity3d建模软件 编辑:程序博客网 时间:2024/04/29 16:41

class access there's an extra set of constraints:

 1. There can be only one public class per compilation unit(file). The idea is that each compilation unit has a single public interface represented by that public class. It can have as many supporting package-access classes as you want. If you have more than one public class inside a compilation unit, the compiler will give you an error message. 

 2. The name of the public class must exactly match the name of the file containing the compilation unit, including capitalization. so for Widget, the name of the file must be Widget.java, not widget.java or WIDGET.java Again, you'll get a compile-time error if they don't agree.

3. It is possible, thougt not typical, to have  a compilation unit with no public class at all. In this case, you can name the file whatever you like.

原创粉丝点击