Hello, ranches!
Why does run-time exception occur?
What is the difference between Hashtable and HashMap classes?
public class J {
public static void main(String[] args) throws Exception {
HashMap hm = new HashMap();
hm.put(null, null);
System.out.println(hm);
Thread.sleep(1000);
Hashtable ht = new Hashtable();
ht.put(null, null);
System.out.println(ht);
}
}
Result:
{null=null}
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:397)
at fgff.Jhsdhdjshdjhsdjhjhjsdhjs.main(J.java:28)
Exception in thread "main"
Alexey