How to initialize an array in Java

Java 8Object Oriented ProgrammingProgramming

Following example shows how to create and initialize an array.

Example

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 14:27:24
Advertisements