Static,final.
(1) Final:
Final: It belongs to the "final state", meaning that it cannot be changed. You can modify Non-abstract classes, methods that are not abstract classes, and so on. Anyway, you can't change the assignment again.
Note: 1 The FINA class cannot be inherited, so it has no subclasses.
2 final cannot be used to modify the construction method.
3 The final method can be inherited, but not be overwritten
4 Final Once the value is assigned, it cannot be changed
5 final container, such as list, the container cannot be changed, but the contents of the container can be changed.
(2) Static:
Static: Represents "Static", "global", which can be used to modify variables, and methods can also be used to form static blocks of code.
A member or member method that is modified by static is independent of the class, and it does not depend on an instance that is shared by all instances, that is, as long as the class is loaded, the JVM can run the memory area to find them according to the method name.
You do not need to create an instance beforehand,
Think of it like that, static modified variables, only one copy in memory, all instances share the copy, but if it is an instance variable, each time you create an instance, you create more data.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/
Static code block:
A static code block is also called a code block, which is a static block of statements that is independent of class members in a class, can have multiple, can be positioned casually, it is not in any method body, and the JVM executes these static blocks of code when it loads classes, if there are multiple static code blocks, The JVM executes them sequentially in the order in which they appear in the class, and each code block is executed once
Private static final String good = "G"; It means that the string "G" can be replaced with good in the program.
Generic type:
Generics are the avoidance of repetitive boxing and unboxing such as collection list<strunt> studentlist=new arraylist<student> ();
You can add student objects directly to the collection.
Studentlist.add (STUDENT1);
Studentlist.add (Student2);
...
If so list studentlist=new ArrayList ();
Studentlist.add (STUDENT1);
Studentlist.add (Student2);
So, if you want to traverse the collection,
for (Object o:studentlist) {
Student oo= (Student) o;//need type conversions here
}
And the first one can be directly
for (Student o:studentlist) {
O represents the entity of each student and can be obtained without type conversion
Author: blog Park Guo Jiasheng haha