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 difference between the file and randomaccessfile classes?

530


What are data structures in java?

529


What is a package in java? List down various advantages of packages.

755


What is a class in java?

580


What is the final class?

548






What is an escape character in java?

530


when to use ArrayList and when to use HashMap in webApplication.

3883


What is thread life cycle in java?

578


What do you know about the garbage collector?

608


What is difference overloading and overriding?

579


What is the advantage of OOP in java?

657


Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.

833


List some features of the abstract class.

587


Is string pool garbage collected?

545


What is module in project?

515