Is it considered poor style / discourage to ignore the loop variable in a for-each statement in Java?
I have some code looks looks sort of like the following:
public void makeChecklist( final List<File> inputSrcs ){
for( File src : inputSrcs ){
System.out.print( src.getName() + "\t" );
}
System.out.println();
for( File src : inputSrcs ){
//Not using "src" in this body!
System.out.print( "[ ]\t" );
}
System.out.println();
}
Is this a bad idea? Any reason not todo things this way? It just seems so much cleaner than using a regular for-loop.
PS- presume that for the example above I want the checkboxes to appear underneath the names, the example is contrived to ilustrate my question as simply as possible.