Loop through an array in Java

Java 8Object Oriented ProgrammingProgramming

Following example shows how to loop through an array using a foreach loop.

public class Tester {
   public static void main(String[] args) {
      int[] dataArray = {1, 2, 3, 4};
      for(int i: dataArray) {
         System.out.println(i);
      }
   }
}
raja
Published on 06-Feb-2018 12:16:11
Advertisements