基本用法:
- public class Test1 {
- protected void finalize() throws Throwable {
- super.finalize();
- }
- public static void main(String[] args){
Test1 t2 = new Test1();
t2=null;
try {
System.gc();//调用了finalize()方法
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
} - }
- }