Solved

java.lang.ClassCastException: java.util.HashMap

Posted on 2006-10-26
3
1,706 Views
Last Modified: 2008-01-09
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
Comment
Question by:chaitu chaitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17810629
Try

Map empDetailHashMap     = (Map) finalMap.get(new Integer(1));
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 17810630
But please post value of

System.out.println(finalMap.get(new Integer(1).getClass());
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17811509
:-)
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 82
ejb on wildfly 5 48
Why is enum singleton a better approach than static factory 3 52
Java List 4 42
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question