Simple array program

1. Program 1

class Arrayelements

                 public static void main(String args[])
                
 
                                  int a[]=new int[5];//declaration and instantiation 
                                  a[0]=10;//initialization 
                                  a[1]=20
                                  a[2]=70
                                  a[3]=40
                                  a[4]=50
 
                                  //print  the  array 
                                  for(int j=0;j<a.length;j++)//length is the property of array                                                                                       System.out.println(a[j]); 
 
                 }


 

2.  PROGRAM 2

class arrayone

                 public static void main(String args[])
                 {   
                                  int a[]={30,34,35,36};//declaration, instantiation and initialization 
 
                                  //printing array 
                                  for(int j=0;j<a.length;j++)//length is the property of array 
                                                   System.out.println(a[j]); 
 
                 }





Comments