Skip to content

Instantly share code, notes, and snippets.

@jayjaykim
Created September 6, 2016 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayjaykim/56f7df3228a4eab116ee3aa60c816db1 to your computer and use it in GitHub Desktop.
Save jayjaykim/56f7df3228a4eab116ee3aa60c816db1 to your computer and use it in GitHub Desktop.
TestForEach.java
public class TestForeach {
public static void main(String[] args) {
String[] msgs = {"aa", "bb", "cc", "dd"};
String[] msg1 = new String[]{"aa", "bb", "cc", "dd"};
final int size = msg1.length;
for(int i = 0; i < size; i++) {
System.out.println(msgs[i]);
}
// a
// b
System.out.println("-----------");
// for-each
for(String str : msgs) {
System.out.println(str);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment