A Java file , if one class contains a public class , then asked the class name of the Java class public file with the same name .
1, Java in why such provisions ?
2, if the norm , then , can provide the relevant information under the definition of this specification ?
3, which provides for programming What are the benefits ?
---------
seek expert doubts
------ Solution -------------------------------- ------------
Naming Conventions
packages
lowercase.
Consider using the recommended domain-based conventions described in the Java Language Specification, page 107 as prefixes. (For example, EDU.oswego.cs.dl.)
files
The java compiler enforces the convention that file names have the same base name as the public class they define.
Reference : http://g.oswego.edu/dl/html/javaCodingStd.html
JLS should have described themselves look it : http://docs.oracle.com/javase/specs/jls/se7 / jls7.pdf
------ For reference only ------------------------------ ---------
1, each compilation unit ( file ) can have only one public class . Do mean, every series
translation unit can have an open interface, and this interface will be represented by public classes .
you may need , which added to the document class to provide any number of auxiliary functions package privileges. But if this compilation unit which has two or more of the public class , then the compiler will complain .
2. public class name of this compilation unit must be identical to the file name , including the size
write. So for the Widget class , the file name must be Widget.java, can not be widget.java or WIDGET.java. If you do not comply , but also the compiler error
a .
3. compilation unit which can be no public classes , although this is not common, but it is possible
's . At this point, you will be able to play freely for the file name.
------ For reference only -------------------------------------- -
http://blog.csdn.net/bareheadzzq/article/details/6562211
------ For reference only ----------------- ----------------------
LZ java based tutorials take a look at it
------ For reference only ----- ----------------------------------
Thank you, this has been my wish to find, because of the time busy , now bear stickers, sorry ~ ~ ~
没有评论:
发表评论