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
What is the major difference between linkedlist and arraylist?
Can we compare two strings in java?
What are the different ways of creating thread?
Does list maintain insertion order java?
What are the steps involved to create a bean?
Define locale.
Can we extend immutable class?
What is the difference between throw and throws keywords?
What is e in java?
Why are parameters used in functions?
What is a byte array?
What is role of void keyword in declaring functions?
why are wait(), notify() and notifyall() methods defined in the object class? : Java thread
What are runtime exceptions?
What is the difference between actual and formal parameters?