@@ -0,0 +1,697 @@
+package com.dw.lib.test;%0A%0Aclass Book %7B%0A%09boolean checkedOut = false;%0A%0A%09Book(boolean checkOut) %7B%0A%09%09checkedOut = checkOut;%0A%09%7D%0A%0A%09void checkIn() %7B%0A%09%09checkedOut = false;%0A%09%7D%0A%0A%09protected void finalize() %7B%0A%09%09System.out.println(%22xxxxx%22);%0A%09%09if (checkedOut)%0A%09%09%09System.out.println(%22Error: checked out%22);%0A%09%09// Normally, you%E2%80%99ll also do this:%0A%09%09// super.finalize(); // Call the base-class version%0A%09%7D%0A%7D%0A%0Apublic class FinalizeTest %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09Book novel = new Book(true);%0A%09%09// Proper cleanup:%0A%09%09novel.checkIn();%0A%09%09// Drop the reference, forget to clean up:%0A%09%09new Book(true);%0A%0A%09%09// Force garbage collection & finalization:%0A%09%09System.gc();%0A%09%7D%0A%0A%7D%0A

add java finalize very important as dispose