Meaningless Drivel is fun!
The moose likes Java in General and the fly likes Problem With ClassCasting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem With ClassCasting" Watch "Problem With ClassCasting" New topic

Problem With ClassCasting

mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
This is my problem:
if LastName map contains the key of this emp's lastname
extract the value object(an arraylist) from the map and add
the current emp object reference to it
instantiate a new arraylist and add the emp reference to it
then add the last name key and the arraylist value object
to the map
Here is what I have so far:

The problem is that when I run into the second instance of a last name(inmy case smith) it throws a ClassCastException on this line:
What should I do??? It does seem that this is the only forum that I can get serious answers to my problems and I truly appreciate that fact. So thatnk you to anyone who can help me straighten out my code.
[ April 07, 2003: Message edited by: mike hengst ]

Thank you Oh Lord<br />For the white blind light<br />A city rises from the sea<br />I had a splitting headache<br />from which the future's made<br />--morrisson
mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
I have solved the problem. It is adding everybody in now. Now onto the other errors. HA they nver end.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
You are not going to share your solution?

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Problem With ClassCasting
It's not a secret anymore!