-
List Iterator
Hi all,
The remove method is not working in my List iterator code. below mentioned is the code.
import java.util.*;
class Listi
{
public static void main(String[] args)
{
ArrayList <Integer> ai = new ArrayList<Integer>();
ai.add(9);
ai.add(0);
ai.add(8);
ListIterator li = ai.listIterator();
while(li.hasNext())
{
String o = (String)li.next();
if(o.equals("9"))
{
li.remove();
}
System.out.println(o);
}
}
}
Now when i run the above code i get class cast exception. Kindly help!!
Thank you
-
Re: List Iterator
-
Re: List Iterator
problem sovled!! thanks anyways