Cannot cast object to hashmap

hashmap, java

Solution

You can cast res to `HashMap` only if `stub.call(sessionId, "sale.list", "11111")` returns a `HashMap` object.

`[Ljava.lang.HashMap;` indicates that what you are getting is an array of hashMap and not a single HashMap.

Problem

My code: ``` Object res = stub.call(sessionId, "sale.list", "11111"); HashMap<String, String> map = (HashMap<String, String>) res; ``` Converting object into HashMap i got following exception, ``` Exception in thread "main" java.lang.ClassCastException: [Ljava.util.HashMap; cannot be cast to java.util.HashMap ``` Can anyone help me how to retrieve object data?

Original source

Related problems