Darano

enhanced/for-loop

Nov 17th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  1. //Imagine having a String-Array arr[] which is filled with random strings. We wanna print out each String in the array
  2.  
  3. //for-Loop
  4.    for(int i=0; i < arr.length; i++){
  5.             System.out.println(arr[i]);
  6.         }
  7.  
  8. //enhanced for-loop
  9.     for (String s : arr) {
  10.             System.out.println(s);
  11.         }
Advertisement
Add Comment
Please, Sign In to add comment