• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem With ClassCasting

 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
else
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:
((ArrayList)byLast.get(emp.getLastName())).add(emp);
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 ]
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved the problem. It is adding everybody in now. Now onto the other errors. HA they nver end.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not going to share your solution?
Pleeeeeeeese?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic