File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
arivu mathi
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic