Monday, June 22, 2015

Java-Array different way

Java-Array different way

 

import java.util.Scanner;

public class ARRAYmain {

public static void main(String[] args) {
//first way
// int a[]=new int[100];
// a[0]=10;
// a[1]=11;
// a[2]=12;
// System.out.println(a[0]+" "+a[1]+" "+a[1]+" "+a[2]);
//second way
// int b[]={10,20,30};
//
// System.out.println(b[0]+" "+b[1]+" "+b[1]+" ");
//third way

// Scanner v = new Scanner(System.in);
// int cc=10;
// int c[]=new int [cc];

//forth way
int d[]={10,20,30};

for(int i=0;i<d.length;i++)
{
System.out.println(d[i]);
}
}

}

No comments:

Post a Comment