?
Solved

java.lang.ClassCastException: java.util.HashMap

Posted on 2006-10-26
3
Medium Priority
?
1,712 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 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

771 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