TrolloC
05-02-2007, 02:05 PM
Suppose i have the following code:
for ( Iterator it = myList.iterator(); it.hasNext(); )
T element = it.next();
The IntelliJ IDE tells me it is replaceable by for each loop. When i tell it to replace, it then produces the following code:
for ( T t :(Iterable) myList )
T element = t;
But then it says:
Unchecked cast: MyCollection to java.lang.Iterable
Can i overcome this unchecked cast somehow?
myList.iterator() function returns Iterator object btw.
for ( Iterator it = myList.iterator(); it.hasNext(); )
T element = it.next();
The IntelliJ IDE tells me it is replaceable by for each loop. When i tell it to replace, it then produces the following code:
for ( T t :(Iterable) myList )
T element = t;
But then it says:
Unchecked cast: MyCollection to java.lang.Iterable
Can i overcome this unchecked cast somehow?
myList.iterator() function returns Iterator object btw.