Community
Participate
Working Groups
When I compile this code with jdk 1.5 and deactivating (!) the "preserve unused (never read) local variables" in classfile options the generated classfile will throw an Error as ilist.next() is never called: public static void main( String[] args ) { List<String> ilist = new ArrayList<String>(); ilist.add( "Dies" ); ilist.add( "ist" ); ilist.add( "ein" ); ilist.add( "Test" ); int count = 0; for( String o : ilist ) { count++; if( count > 10 ) { throw new Error(); } } } I think this should at least give a warning.
Which build are you using ?
Smells like dup of bug 86487
*** This bug has been marked as a duplicate of 86487 ***