Thinking in java learning notes

xiaoxiao2021-03-06  102

Thinking in java learning notes (written for a long time, find mistakes to tell me, don't let me go down ~~~) ======================== ============================================================================================================================================================================================================= ====== Object creation: Java dynamically creates objects in the bunch. (NEW) allocated in the stack, release memory is the most efficient. Creating an object (Java) is a high-stack Strack: General memory area, and the fastest and most effective distribution of memory is quickly distributed by the stack pointer up and down. Data stored in the stack must know the size and lifecycle, and Java stores references to the object in this area (and some data, such as original type data), but the object itself is not stored in the stack. Pile of Heap: Memory Area. When allocating space, there is no need to know the size and life cycle that needs to be assigned, and it is flexible than Strack. Java objects are stored here.

Original primitive type as the default initial value of class members: Note that the variables of the class member will not have default Boolean = falsechar = / u0000 = nullbyte = (byte) 0short = (short) 0INT = 0long = 0.0d

Method parameters: When Java passes an object, it is actually a reference! (Except Primitive Type)

Comparison of classes: Objects use equals (), original types of ==! = Equals () default is whether the reference is the same, all the classes you have written, must implement the equals () method must be implemented.

Bit operation: & | or ~ non-

Shift operation << Low position 0 Supplement >> High position symbol supplement, 0 negative 1 >>> High position 0 supplement

E value (= 10): float i = 1.39E-2F = 1.39 * 10 (-2) = 0.00139

The overloading method name is the same, the return value, the parameters can overwrite the Overriding name, parameter, value of the same value

The Finalize () GC thread only releases the memory allocated by the NEW. If the memory owns the memory is not a NEW allocation, it is used to clean up by the Finalize (), which is called by GC release within. (Triggered by Java Native Method)

Class initialization (this Huawei written test): 1. Load the Class file (derived class-> base class) 2. Static member initialization (base class -> derived class) (primary class 3.4.5.6 -> post-belonging 3.4.5.6) 3. When the new object, allocate enough memory 4 in HEAP. Get memory clear zero, so that the type variable is automatically assigned, reference is NULL5. Members initialize 6. Constructor Anonymous Internal Class: Initialization Class Variable, Object, can be assigned a static or non-static variable PUBLIC CLASS TEST {static int max; static {max = 100;} int b; {b = 200;}}

Singleton Mode: This class creates some and only one instance object, which must be accessed through the Access () method to access public class test {private test ()} private static test t1 = new test (); public static test access () {Return T1; }

Polymorphism: Dynamic Binding, Running Bind Public Class Test {Public Static Void Add2 (Collection C) {C.Add ("Test"); // Determines the type of C, perform the corresponding add (Object) Obj) Method C.Add ("test");} public static void main (string [] args) {Collection list = new arraylist (); // Upload transformation Upcasting collection set = new hashset (); add2 (list); Add2 (SET); System.out.Println (list); System.out.println (SET);}}

A good constructor, you should use the least workload to set the object, and try to call the method, do you try to call the final / private method

转载请注明原文地址:https://www.9cbs.com/read-100589.html

New Post(0)