public class HowToUseArray {
public static void main(String[] args)
{
int [] aryA = {1,2};
int [] aryB = new int[2];
aryB[0] = 1;
aryB[1] = 2;
int [] aryC = new int[]{1,2};
//Wrong usage
//int [] aryD = new int[2]{1,2};
//Cannot define dimension expressions when an array initializer is provided
//int aryE[4];
}
}
public static void main(String[] args)
{
//Correct usage
int [] ary;
int [] aryA = {1,2};
int [] aryB = new int[2];
aryB[0] = 1;
aryB[1] = 2;
int [] aryC = new int[]{1,2};
//Wrong usage
//int [] aryD = new int[2]{1,2};
//Cannot define dimension expressions when an array initializer is provided
//int aryE[4];
}
}