Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes plz explain the difference........ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "plz explain the difference........" Watch "plz explain the difference........" New topic
Author

plz explain the difference........

arivu mathi
Ranch Hand

Joined: Jun 26, 2006
Posts: 38
import java.util.*;
public class Test2{
public static void main(String a[]){
Map s = new Hashtable();
s.put(null,null);
System.out.println(s);
}
}
What is the output?

NullPointerException



import java.util.*;
public class Test3{
public static void main(String a[]){
Map s = new WeakHashMap(10);
s.put(null,null);
System.out.println(s);
}
}

What is the output?

[null = null]
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Hashtable API:
The Hashtable class implements a hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.

WeakHashMap API:
Both null values and the null key are supported. This class has performance characteristics similar to those of the HashMap class, and has the same efficiency parameters of initial capacity and load factor.
 
jQuery in Action, 2nd edition
 
subject: plz explain the difference........