What is the problem with the following code?
class xyz
{
int[] array=new int[3];
array[0]=0;
array[1]=1;
array[2]=2;
public static void main(String[] args)
{
xyz a=new xyz();
System.out.println(a.array[0]+" "+a.array[1]+" "+a.array[2]);
}
}
I am not able to initialize the array within the class but it works if it is initialized within a method of the class or the main function.