declaration of arrays

Write a program to show declaration of array.

import java.util.Scanner;
class P15ArrayDeclaration
{
   public static void main()
   {
      int[] a;
      a= new int[3]; 
      a[1]=4; // value of array a at index 1 is 4
      int[] b= new int[]{17,52,64,53}; // declaration and intilisation of array
      System.out.println("Value of array b at index 2 is " +b[2]); // 64
      System.out.println("Value of array a at index 2 is " +a[2]); // deafault value of integer type array is 0
      System.out.println("Address of array a  " +a);//
      
      //an (new int[] { 2,4}); anonomus array
      System.out.println("Anonomous " +new int[] { 2,4});
   }
}



For any desired program, please comment below. We will try our best to make that program available.

Comments

Popular Posts