Arrays in Java

an array, it is a object variable (box,container), which is a variable in a position to take up more than one object of the same type and manage it

example of arrays in java

package arrays;
 
public class Arrays {
 
    public static void main(String[] args) {
           int[] digits1; // Reference Variable
           int[] digits2= new int[5]; // Definition with 5 x Integer
           int[] digits3= {1,2,3,4,5}; // Definie with initialization ( 5 Integer)
 
           // pass Element by element
           for (int i=0; i< digits3.length ; i++) {
               digits2[i]=digits3[i];
           }
           digits1 = digits2.clone(); // duplicate the array
 
 
           for (int i=0; i< digits1.length ; i++) {
               System.out.print(digits1[i]+" ");
           }
           System.out.println();
 
           for (int i=0; i< digits2.length ; i++) {
               System.out.print(digits2[i]+" ");
           }
           System.out.println();
 
           for (int i=0; i< digits3.length ; i++) {
               System.out.print(digits3[i]+" ");
           }
           System.out.println();
 
 
    }
}

output of array in java

   1 2 3 4 5 
   1 2 3 4 5 
   1 2 3 4 5