- Automatic packing, unpacking
1 Public classIntegertest {2 3@Test4 Public voidConstpool () {5//when auto-boxing, call the ValueOf method, which will set the constant pool to 128 to 127 by default6 Integer f1 = +, F2 = f3, F4 = 150; 7 8 System.out.println (f1 = = F2);//true in constant pool9 System.out.println (F3 = = F4);//false in a very variable pool, with different object references10 }11 12@Test13 Public voidautoboxing () {Integer A =NewInteger (3);Integer B = 3;16intc = 3;System.out.println (A = = B);//false different referencesSystem.out.println (A = = c);//true a automatically unboxing into int type20 }21}
- Stack, heap (heap), static area
Usually we define a variable of a basic data type, a reference to an object, and a field save for a function call to use the in-memory stack space, while the object created by the new keyword and the constructor is placed in the heap space, and the literal in the program (literal) is written as 100, "Hello" And constants are placed in the static zone. Stack space is the fastest, but the stack is small, usually a large number of objects are placed in the heap space, in theory, the entire memory is not used by other processes in the space or even the hard disk virtual memory can be used as a heap space.
New String ("Hello");
In the above statement, the variable str is placed on the stack, the string object created with new is placed on the heap, and the literal "hello" is placed in the static area.
The subclass inherits the parameterless construction method of the parent class by default. The constructor with parameters cannot be inherited, nor can it be overridden, because the class names are different.
"Original" Java Side question notes