aspose file tools*
The moose likes Beginning Java and the fly likes Hashtable allowing null values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hashtable allowing null values" Watch "Hashtable allowing null values" New topic

Hashtable allowing null values

Ra Sank

Joined: Jun 02, 2008
Posts: 14

I have tried the below code and it is allowing both null as key as well as values. based on difference between HashMap and Hashtable several tutorials mentioning null is not allowable in Hashtable afterwards of Synchronized difference. Kindly clarify if you have any idea on this.
If these statements are correct then is there any other difference between HashMap and Hashtable?

Learning Java.
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

because you are passing a string that contains the value "null" instead passing null keyword that represent nothing.
Ra Sank

Joined: Jun 02, 2008
Posts: 14
Hi Wirianto,

Thanks for your updates.

Can you please tell me whether i can do like this for the check

ht.put(null,null); Which doesnt affect the Hashtable?.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19541

That code will throw a NullPointerException with Hashtable.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Hashtable allowing null values
Similar Threads
Enthuware mock doubt!!
is it a valid jsp code
What is the difference between Hashtable and HashMap classes?
enthuware question
Sorting Vector of Hashtables by a Hashtable value