Java HashMap with nested String or ArrayList
<p>New to Java and was curious if there was a way to make the Value of a HashMap either a string or an ArrayList:</p>

<pre><code>HashMap&lt;String, HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt; map = new HashMap&lt;String, HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt;();
map.putIfAbsent("238991", new HashMap&lt;String, ArrayList&lt;String&gt;&gt;());
map.get("238991").put("OrderID", new ArrayList&lt;&gt;());
map.get("238991").get("OrderID").add("1234H");
map.get("238991").get("OrderID").add("1233B");
map.get("238991").put("Name", new ArrayList&lt;&gt;());
map.get("238991").get("Name").add("Smith, John");
System.out.println(map.get("238991"));
System.out.println(map.get("238991").get("Name").get(0));
</code></pre>

<p>I would prefer to only add a String if I can for the Name rather than just accessing the first element of the list. Is this possible?</p>