Im using HashMap in my application and sometimes I need to add a key (String) with a null value (emty array list of objects). But Netbeans 7.4 says:
Exception in thread "main" java.lang.NullPointerException
at test.Version.main(Version.java:35)
Java Result: 1
to this code:
HashMap<String, ArrayList<Object[]>> d = null;
ArrayList<Object[]> a;
a = new ArrayList<>();
d.put("key1", a);
I dont want to use a MultiMap. Is there any other way how to solve it easily?
dto an instance ofHashMap. You're trying to callputon anullreference.d = new HasMap<String, ArrayList<Object>>();