One, stack memory and heap memory in Java
1. Stack memory: Store local variables, out of scope will be recycled;
2. Heap Memory: Created object with Java garbage collector recycle.
Second, static and the survival of the class, non-static and object coexistence dead!!
Third, the comparison of objects:
1.==: Compare the value in the stack memory (address)
2.equals: Compare the content, rewrite the method only makes sense!!
The function parameter is: The basic type is the transfer of the value of the copy, the reference type is the delivery of the reference!!
Five, the understanding of the string:
New comes out of the difference between the object and the direct write!!!
1String S1 =NewString ("ABC"); //2 an object 2String s2 =NewString ("ABC"); //2 an object 3 4System.out.println ("S1 = = S2:" + (S1 = = s2));//false5System.out.println ("S1.equals (S2):" + s1.equals (S2));//true6 7 8String s3 = "ABC";9String S4 = "ABC";Ten OneSystem.out.println ("S3 = = S4:" + (s3 = = S4));//true ASystem.out.println ("S3.equals (S4):" + s3.equals (S4));//true
Six, GetClass:
Class byte-code acquisition:
1. Object acquisition; GetClass ()
2. Access by class; class
3.Class Forname method is obtained. Class.forName ("com.westos.javase.lesson04_2.Person"); -------> Note full name
Vii. Abstract class:
Abstract classes are born to be inherited;
An abstract class cannot be instantiated, but a variable can be defined to point to a subclass object;
Its subclasses must override all methods, or else they must be declared as abstract classes;
Abstract classes can have no abstract methods;
Abstract class and ordinary class, there are construction methods!!!
Eight, interface
All the methods in the interface are abstract-----> public abstract
The variables in the interface are-------> public static final
A class can inherit only one class, but may implement multiple interfaces: public class Superman extends person implements Run_able,flyable {}
Solve the problem of not much inheritance!!
Nine, the difference between abstract class and interface:
An abstract class is an inheritance, an interface is an implementation;
Abstract class is a; interfaces are like A;
The abstract class defines the function within the system, and the interface defines the extended function outside the system!!
Java Object-Oriented understanding