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 will be the default values of all the elements of an array defined as an instance variable?

780


What does java stand for?

786


What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

768


Why packages are used?

858


What is an eror in java?

806


why Java does not support multiple inheritances?

920


What is the diffrence between inner class and nested class?

817


Convert a BST into a DLL and DLL to BST in place.

874


explain autoboxing in java?

775


Where are global variables stored?

698


Can we split string with in java?

749


Can we declare main () method as non static?

717


Is double bigger than float?

748


What is application tier?

782


What is indexof in java?

738