import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        System.out.println("3 ways to create Array");
  
        int []marks;   // declaration 
        marks= new int [6]; // memory allocation 
        
        marks[0]=20;
        marks[1]=49;
        marks[2]=50;
        marks[3]=60;
        marks[4]=55;
        System.out.println(marks[4]);
        
        // 2nd type
     int []marks1 = new int [5];  
     //  declaration+ memory allocation 
       
        marks1[0]=20;
        marks1[1]=49;
        marks1[2]=50;
        marks1[3]=60;
        marks1[4]=55;
         System.out.println(marks1[2]);
        
        
     //3rd type  
     // declaration+ initialize 
     int []marks2 = {20,49,50,60};
     
      System.out.println(marks2[1]);
  
  // now we have to print all arrays elements
    System.out.println("array all elements");
   
    for (int a=0; a<marks.length ;a++ )
  {
    System.out.println(marks[a]);

      
  }
   
   
    // in reverse 
      System.out.println("array elements in reverse order");   
        
        int rr = marks2.length;
        for (int i=0; i<rr ; )
        {
            --rr;
             System.out.println(marks[rr]);
            
        }
        
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: