1. Initializing blocks
Actually initializing the block is an illusion, after compiling the Java class with the Javac command, the initialization block in the Java class disappears--the code in the initialization block is "restored" to each constructor, and is in front of all the code in the constructor.
2.p125-p128 Self-boxing, his own initiative to remove the box does not understand
3. Packing class
4. Single Case class
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">
Instance:
Provides a static method. Used to return a singleton instance //the method can increase its own definition control. Ensure that only one Singleton object is generated public static Singleton getinstance () { //assumes instance is null. Indicates that the singleton object has not been created //assumed that instance is not NULL. Indicates that the singleton object has been created //will not create a new instance again if (instance = = null) { //Create a singleton object. and cache it up instance = new Singleton (); } return instance; }
5.final modifies the difference between a primitive type variable and a reference type variable
When you use final to decorate a primitive type variable. You cannot assign a value again to a primitive type variable. So the basic type variable cannot be changed, but for a reference type variable, it saves a reference, and final only guarantees that the address referenced by the reference type variable will not change, that is, the same object is referenced all the time, but the object can be completely changed.
6. Final variable that can run "macro substitution"
For a final variable. Whether it is a class variable, an instance variable, or a local variable. Only if the variable satisfies three conditions, the final variable is no longer a variable, but is equivalent to a direct quantity.
- Decorating with the final modifier
- An initial value was specified when the final variable was defined
- The initial value can be determined at compile time.
One important use of the final modifier is to define a "macro variable." When the final variable is defined, an initial value is specified for the variable. And the initial value can be determined at compile time, then the final variable is essentially a "macro variable". The compiler will replace all of the variables in the program with the value of the variable directly. Java uses a constant pool to manage the direct amount of previously used strings, such as running string a = "Java"; After the statement, a string "Java" is cached in the constant pool, assuming that the program runs string b = "Java" again; The system causes B to point directly to "Java" in the constant pool, so a = = B returns True.
7. subclasses of inner class non-static inner classes are not necessarily internal classes. It can be an external class. A subclass instance of a non-static inner class, however, needs to retain a reference to the object of the outer class whose parent class resides. In other words, if an object of an inner class subclass exists, there must be an outer class object corresponding to it.
8.effectively final
Read "Crazy Java Handout" notes summary Three