View Single Post
  #2 (permalink)  
Old 03-08-2008, 08:03 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
Check out the third–from–last sentence, "Similarly it is not ...", at the bottom of this page in the javadocs guide The For-Each Loop.
Code:
public class Test { public static void main(String[] args) { String[] strs = new String[5]; int count = 0; for(String s : strs) { System.out.println("count = " + count++); s = "alfred e neuman"; } for(String s : strs) System.out.println(s); System.out.println("----------------"); for(int j =0; j < strs.length; j++) strs[j] = "tally ho"; for(String s : strs) System.out.println(s); } }
Reply With Quote