Java---------> Classes and objects
(i) important points of knowledge
Static usage:
When 1,static acts on a method: The method belongs to a class method that calls this method without objects of this class (which can be called directly from a class), with the limitation that only static methods and data cannot be called, and the This and super keywords cannot be referenced in any way.
2,static action on a variable: equivalent to a global variable, static with the last call (the number of times the statistic method is executed), static{} such static block precedence execution, regardless of order, the static variable will only need to initialize once, that is not allocated memory, If a normal global variable is called, it will be executed once for each class.
3,static acts on the class: that is, the internal static class, can be directly as a normal class to come out in detail see here
This usage:
1, call the property in this class, 2, call the other methods in this class (static method cannot) 3, return the value of the object (for example: return this)
Passing of parameters
Pass-through: value passing (arguments passed to formal parameters), not object passing, arguments passed are either basic type (pass value) or reference type (parameter is address value)
Pass multiple parameters of the same type, such as test (int i, String ... books)
Super Method: Call a method of the parent class, such as super. Member variable, super (method parameter)
Final keyword:
1,final modifier primitives and reference type differences: base type: Value invariant, reference type: The reference address is the same, the object content can be changed.
2,final-Modified methods cannot be overridden
3,final-Modified classes cannot have child classes
Overloaded Method: The method name is the same as the parameter list, regardless of the return type
Variable Description:
Access rights:
categories of packages:
= = and equal some easy to forget points:
1, for the basic type variable, as long as two variables are numeric type and the value is equal, then = = is established as (3==3.0f) True, and (65== ' A ') True, for the object, the reference type is required to point to the same object, then returns True
2, string constant pool, such as String a= "23"; String b= "2", String c= "3"; String D=b+c; A==d false;a=b+ "3" false;//because it cannot be determined at compile time (the type cannot be recognized directly at the time of assignment.) )
Features of abstract classes and abstract methods:
1, abstract classes and abstract methods must be modified with an abstract method, and there is no method body, such as public abstract String test ();
2, abstract classes cannot be instantiated (that is, new)
3, abstract classes can contain member variables, method bodies (abstract methods and common methods), constructors, initialization blocks, inner classes (interfaces, enumerations)
4, classes containing abstract methods can only be defined as abstract classes
Interface:
1, abstract class can contain member variables, method body (abstract method and default method, class method (Static) (Java8 allowed)), inner class (public static decoration)
2, member variable default public static final; method default is public abstract
3, the interface supports multiple inheritance,
Inner class:
1, the inner class has (private,protected,static) three permission access, internal access to external variables, and external cannot directly access internal members (can borrow objects).
2, non-static inner classes cannot contain static variables, methods, initial blocks
3, static inner class: Static classes cannot access instance members (that is, non-static)
4, local inner class: Declared in method, cannot set static and access rights,
5, Anonymous class: 1, cannot be abstract class, 2, cannot define constructor method (anonymous class has no class name);
Enum classes differ from ordinary classes:
garbage collection mechanism:
Three state transitions where heap memory objects are:
Jar File Common commands:
1, create the jar:jar cvf hello.jar hello//c:创建 f:文件信息 v:详细过程报告
2. Unpack the jar:jar xvf hello.jar //x:解压
3. Add the file to the jar:jar uf hello.jar HelloWorld.java //u:添加
4, show jar contents: Jar TVF Hello.jar
Java-------->> Classes and objects