Sunday, February 22, 2009

sample example for array construction



//sample example for array construction
package arrays;

public class ArrayDemo {


public static void main(String[] args) {

// valid constractions

int[] aa=new int[6];
int s[]=new int[0];
int [][] a= new int [3][2];

// not valid array construction

int a=new int[6]; (array declaration missed)
int [] a1=new int []; (size must declare)
int [] a=new int [-6]; (-ve value not allowed)
int [] a1=new int [2147483648]; (allowed only int range)
int [][] a=new int[][2];
}

}



0 comments:

Post a Comment