What is an array and what is it used for?

Java Programming Java8Object Oriented Programming

An array is a data container which holds a fixed length of elements of homogeneous data type. It is used to store the elements of the same datatype.

Example

Live Demo

public class ArrayExample {
   public static void main(String args[]){
      int myArray[] = {44, 69, 89, 635};
      
      for (int i = 0; i<myArray.length; i++){
         System.out.println(myArray[i]);
      }
   }
}

Output

44
69
89
635
raja
Published on 23-Apr-2018 01:42:07
Advertisements