1, the life cycle of the object (1) finalize package cn.sdut;
public class AA {int x=100;
int y=100;
Public AA () {x=10;
y=20;
public AA (int x, int y) {super ();
this.x = x;
This.y = y;
@Override protected void Finalize () throws Throwable {System.out.println ("AA finalize ...");
Super.finalize ();
public void mm () {System.out.println (x+ "= =" +y);
public static void Main (string[] args) {AA aa=new aa ();
AA.MM ();
... aa=null, and the other is the same.
System.GC ();
}//(2) static package cn.sdut;
public class AA {static{//Static code block a program in which a static block of code executes the first System.out.println ("Static Block ..."); static int x=100;
Class variable, static variable int y=100;
Public AA () {y=20;
public AA (int x, int y) {super ();
this.x = x;
This.y = y;
@Override protected void Finalize () throws Throwable {System.out.println ("AA finalize ...");
Super.finalize (); public static void mm ()//class method, static method {System.out.println (x+ "=");
public static void Main (string[] args) {AA aa=new aa ();
System.out.println (aa.x);
x+=20;
AA bb=new AA ();
System.out.println (aa.x);
System.out.println (aa.x);
AA.MM ();
}//2, Abstract//(1) Abstraction classes cannot be instantiated, (2) Abstract classes can define abstract methods or Non-abstract methods, and (3) classes that contain abstract methods must be abstract classes.
Package Cn.sdut;
Public abstract class AA {static{System.out.println ("Static Block ...");
static int x=100;
int y=100;
Public AA () {y=20;
public AA (int x, int y) {super ();
this.x = x;
This.y = y;
@Override protected void Finalize () throws Throwable {System.out.println ("AA finalize ...");
Super.finalize ();
public abstract void mm ();
public void mm2 () {};
public static void Main (string[] args {}} 3, final modifier variable, only 1 times assigned; Cosmetic method, subclass cannot override (overwrite) method.
Package Cn.sdut;
public class AA {final int x;
int y=100;
Public AA () {x=20;
y=20;
public AA (int x, int y) {super ();
this.x = x;
This.y = y; Public final VOID mm2 () {};
public static void Main (string[] args) {final int a=10;
} 4, this package cn.sdut;
public class AA {final int x;
int y=100;
int z;
Public AA () {this (20,20);
z=10;
public AA (int x, int y) {this.x = x;
This.y = y;
public void mm2 () {System.out.println (this.x+ "= =" +this.y);
};
public void Mm3 () {this.mm2 ();
};
public static void Main (string[] args) {}}