为什么 java.lang.String 是大写的?
Why is java.lang.String capitalized the way it is?
为什么字符串 class 是大写的,而 java 和 lang 是小写的,另一个例子是 System.out.println,println 是一个小写的方法,但为什么是小写?我是不是遗漏了什么或者有人不遵守他们自己的规则?
Class 名称的第一个字母大写。根据命名约定,包名称始终为小写。
java.lang
是包名
String
是 Class 名字
对于 System.out.println() 它分解为这样
System
是class名字,所以首字母大写
out
是 public 静态字段,属于 PrintStream
class,因此可以直接访问。
println()
是PrintStream
class
的一个方法
用法示例为System.out.println("Hello World");
有关此内容的更多信息,请参阅此处的文档 http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#out
"Naming conventions make programs more understandable by making them easier to read. They can also give information about the function of the identifier-for example, whether it's a constant, package, or class-which can be helpful in understanding the code."
因此,在您的示例中,"java.lang" 是包名称,"String" 是遵循 Java 命名约定的 class 名称。
System.out.println()
这里整个东西不是方法名。这里只有 println()
是方法名,而且是小写的。 System
是 class 名称,out
代表我不需要隐式创建的标准对象。
此外 java.lang
是包名,String
是 class 名称。 java.lang.String
作为一个整体不是一个 class 名称,它是完全限定的 class name.Each 包名称中的组总是以 lowercase.And 开头,这在 [=23] 中是习惯的=] 按照这个约定写 class 和包名。
为什么字符串 class 是大写的,而 java 和 lang 是小写的,另一个例子是 System.out.println,println 是一个小写的方法,但为什么是小写?我是不是遗漏了什么或者有人不遵守他们自己的规则?
Class 名称的第一个字母大写。根据命名约定,包名称始终为小写。
java.lang
是包名
String
是 Class 名字
对于 System.out.println() 它分解为这样
System
是class名字,所以首字母大写
out
是 public 静态字段,属于 PrintStream
class,因此可以直接访问。
println()
是PrintStream
class
用法示例为System.out.println("Hello World");
有关此内容的更多信息,请参阅此处的文档 http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#out
"Naming conventions make programs more understandable by making them easier to read. They can also give information about the function of the identifier-for example, whether it's a constant, package, or class-which can be helpful in understanding the code."
因此,在您的示例中,"java.lang" 是包名称,"String" 是遵循 Java 命名约定的 class 名称。
System.out.println()
这里整个东西不是方法名。这里只有 println()
是方法名,而且是小写的。 System
是 class 名称,out
代表我不需要隐式创建的标准对象。
此外 java.lang
是包名,String
是 class 名称。 java.lang.String
作为一个整体不是一个 class 名称,它是完全限定的 class name.Each 包名称中的组总是以 lowercase.And 开头,这在 [=23] 中是习惯的=] 按照这个约定写 class 和包名。