【读书笔记】Core Java for the Impatient 第二章
Object-Oriented Programming
Default InitializationInstance variable is automatically set to a default value: numbers to 0,boolean values to false,and object references to null. Static Variables and MethodsSince static methods don’t operate on objects,you cannot access instance variables from a static method. However,static methods can access the static variables in their class PackagesIt is a good idea to run javac with the -d option. Then the class files are generated in a separate directory,without cluttering up the source tree,and they have the correct subdirectory structure. A source file can contain multiple classes,but at most one of them can be declared public. If a source file has a public class,its name must match the class name. Nested and Inner ClassesNested ClassesUse a static nested class when the instances of the nested class don’t
There is nothing special about the Item class,except for access control. Inner Classes
A method of an inner class can access instance variables and methods of its outer class. In this case,they are the instance variables of the outer class object that created it Comments//TODO (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |