Results 1 to 3 of 3
Thread: ClassCastException
- 06-25-2007, 08:30 PM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 110
- Rep Power
- 0
ClassCastException
I did an iterator
I have different objects
Some of them are cars, and other trucks (both of them are subclass of Vehicles )
When I iterate in every element of the vector
this error appears:
ClassCastException
this is my code
Java Code:while it.hastnext() if (it.next() instanceof truck auxVehicle = (truck)it.next(); if (it.next() instanceof Car auxVehicle = (Auto)it.next();
- 07-04-2007, 05:25 AM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
your code is incorrect
when you do "ite.next" you are calling a new object inside of the list
- 07-04-2007, 05:26 AM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 164
- Rep Power
- 6
Similar Threads
-
ClassCastException in TreeSet
By pHew in forum New To JavaReplies: 2Last Post: 01-16-2008, 12:20 AM -
Problem with vector, java.lang.ClassCastException
By paul in forum New To JavaReplies: 1Last Post: 07-16-2007, 04:31 PM -
ClassCastException
By Felissa in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks