M3P3S M3P3S - 4 months ago 28
Java Question

I don't make HashMap in HashMap {Java}

I need to put a

HashMap
to another
HashMap
, but never get second
HashMap
values.

Example:

HashMap<UUID, HashMap<String, String>> hash = new....


But the
hash.get(#UUID)
call returns an
Object
instance, not a
String
. How to create
HashMap
with 3 keys like
HashMap<K, V, C>
?

Thanks.

Answer

You'd need to call a second time get

hash.get(/*key*/) // This will get you the inner HashMap (thus the Object you're talking about)
    .get(/*key*/); // This will get you a String object from the inner HashMap