Thursday, March 5, 2009

source code WeakHashMap



package myutil;

import java.util.WeakHashMap;

class Temp {
public void finalize() {
System.out.println("finalize() Called");
}
public String toString() {
return "Temp";
}
}
public class WeakHashMapEx1 {
public static void main(String[] args) {
WeakHashMap map=new WeakHashMap();
Temp t=new Temp();
map.put(t,"orange");
t=null;
System.gc();
System.out.println("The Map"+map);
}
}

output:
finalize() Called
The Map{}



0 comments:

Post a Comment