Static member variables, anonymous functions, anonymous implementation class


Summary: 1 is modified static member variables (member variables + member method) belong to the class, not an object belonging to this class; that is, more than one object in the access and modification modified static member variables in which an object static value of the variable is modified
static values from other objects also change with the value of the shared variable that is a member of a plurality of static member variable is assigned to the last criterion.
2 is modified static member variables and methods and can be direct access is recommended by the class name; class name attribute member variables;. method class member variable name (parameter)
3.main static method is performed only for the program entry method, which does not belong to any object, can be defined in any class ; and
4. definition of static constant: final public static data type variable name = value; and complete the definition is modified, the full name of the variable to write capital letters, words _ directly connected with
a member variable with a default interface 5 public static final modified
6. Therefore interface variables are static constant; modified with public static final; Interface is not constructor must be assigned; can be connected . The name of the variable name accessed
7. variables with the static properties and the assignment is not belong to any object class; modified static variable data into the shared area assigned to the last value of the standard; variables become the value
8. because modified with static methods and properties can be adjusted directly by the class name; so do not use private modification; the private into public, do not need to set and get methods;
9.Student.name; because the name in the Student class is modified static so the direct class name of the class. method calls the attribute name on the line and the data is shared
10.Student.show () because in the Student category shwo () method has been modified into a static method static so you can direct the class name method name () call.
11.static modified static member variables do not enter into the area of data sharing method; however Common methods and properties into the stack will address assigned after the assignment to a received object, as modified static methods and variables not into the heap does not address
only inside the shared area; therefore all shared a modified static variable data
12 static methods can not call non-static methods and variables, because the static methods and variables appear as the class together and compile, compile the order of precedence to the object and the main method, if you call non-static methods and variables in a static method will complain,
because in the static the method of translation of non-static methods and variables have not been a compile error will not find the object
13. the static methods of operation or to push it into the data and values to be shared data area
14. the static compile and run the order of priority the object and the main method, so a static member can not call non-static member variables and static methods can not enter data in this and super, data and value Shared area (static area)
15.Fu FU = new new Zi () fu.i; because it is polymorphic so that i i call the parent class is not a subclass; downcast tone class needs to call the unique subclass the methods and variables; even add static static modification i parent class is called
16.fu.show (); polymorphic tone method, the compiler run to see to see the parent class subclass, if coupled with static then becomes static compile and run the parent should see
17 member variables: normal polymorphism: compile and run all look the parent class; plus static polymorphism modified static variables: run and compile all look the parent class
18. the member method: normal polymorphic: compiling see the parent class, subclass run to see, plus the static method static polymorphic modifications: run and compile all see the parent class
19. Internal classes: Class written inside the other classes, can be written in other members of the class of position location or locally (inside the class members, class partial internal (defined as methods and variables)); in this case other types of written inside the class is called inner classes, other classes outside the class called
20. If the inside of a class can also write or include other categories such as automotive engine category includes the class, then we call class is the internal engine, automobiles outside the class is
defined in 21. method inner class: the process is to define a normal class also contain various modifiers / inheritance / implementation; inner class attributes and methods direct methods outside the class
22. the class members of the inner: outer class class class internal modifiers { }} else {class codes; access internal classes: class name inside the external variable name = new class name external column name () .new internal class name ();
23. partial inner classes: class outer class {public void show () {class inner class {other code}}; partial inner class access: in which method the external class directly new internal class object and to direct calls on the line
public void show () {class inner class {public void in () {} } new internal class () in ();} direct Calls on the line
23.bin directory folder are .class file is compiled machine language, is delivered to the customer
24.java directory folder are .java file, the original file is written by a programmer, is their own stay
25. anonymous inner classes, it is a local inner class; temporary definition of a subclass of the specified type, this object is immediately created just defined
26. format: new parent class or interface () {}; for anonymous Therefore, no internal class name is the name of a gang with a borrowed the parent class to pick polymorphism, and call methods and properties; variable name = new parent class or superclass interfaces () {}
27.public static void main (String [] args) {
() {Where the number of multi-state applications Smoke smoke = new Smoke, subclass new Smoke () object is assigned to the parent Smoke smoke; because the anonymous inner class name so you have no reference to the parent class assignment, eliminating the need to create a written an implementation class
public void smoke () {system.out.println ( " drink")} where anonymous inner classes to directly write methods; smoking new () who they where new anonymous inner classes
28.Smoke smoke = new smoke () If the Smoke is a general category then this is the new target for Smoke; Smoke but here it is not possible new target is the interface so here Smoke smoke = new Smoke () is the new anonymous inner classes
29. anonymous inner class because it is not no name downward transition, if you want to tone unique class methods and properties of the parent class assignment do not directly polymorphism in new Smoke () {} point out on the line.
30. a configuration block: is a variable defined in the class members in position ; preferentially executed and create an object constructor will be executed each time; public class Person {pubic Person ( ) { constructor}}} {configuration code block
31. the static code block: the position of member variable is defined, with static modification; takes precedence over the main method Line, in preference to the constructor execution priority in all execution and performed only once
public class Person {public Person () { } constructor configured block {} static {} static block of code};
32.java package: what we computer folder to store class files; when a lot of class, we will only be managed with multiple packets, called subcontract management
33.public: All packages are available
34.protected: sub-class of this package and other packages available
35.default: the same package (this package) under use; do not write modifiers on the default variable is the default
36.private: use under similar (in this category)

Guess you like

Origin www.cnblogs.com/hankai2735/p/11295269.html