• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1729
  • Last Modified:

java.lang.ClassCastException: java.util.HashMap

i am adding like this while adding;while retreving back i am getting java.lang.ClassCastException: java.util.HashMap

resultMap.put(new Integer(0),empDetailObject);
resultMap.put(new Integer(1),empDetailHashMap);
 finalMap.put(new Integer(0),resultMap);    // Is it correct way to add it to finalMap



while  retreving i am doing  like this;


empDetails = (EmpDetails) finalMap.get(new Integer(0));
HashMap empDetailHashMap      = (HashMap) finalMap.get(new Integer(1));
0
chaitu chaitu
Asked:
chaitu chaitu
  • 3
1 Solution
 
CEHJCommented:
Try

Map empDetailHashMap     = (Map) finalMap.get(new Integer(1));
0
 
CEHJCommented:
But please post value of

System.out.println(finalMap.get(new Integer(1).getClass());
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now