File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: plz explain the difference........
 
Similar Threads
Question #6 from Doug's book
HashTable
BinarySearch
for each
HashMap