why HashTable not allow null key and value

Answer Posted / naveen

There is null check in the put method implementation of
hashtable, so it does not support null values and null keys.


public Object put(Object key, Object value) {
// Make sure the value is not null
if (value == null) throw new NullPointerException();
}

above is HashTable put method logic implemented by Sun.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the syntax and characteristics of a lambda expression?

813


What happens when a thrown exception is not handled?

809


How many bytes is double?

756


How can you set the applet size?

830


Can a static block throw exception?

869


how can i use a nonsynchronized hashtable?

2332


What are facelets templates?

805


what is aggregation in java?

787


What classes of exceptions may be caught by a catch clause in java programming?

956


What initialize variables?

726


Explain the difference between string, stringbuffer and stringbuilder in java?

789


What is the meaning of 3 dots in java?

898


What are controls and their different types in awt?

855


Explain about member inner classes?

824


Explain notifyall() method of object class ?

877