Hello ,
i am beginner programmer.
i am trying to initialize an Array in the constructor , but i am stuck here,
Whats wrong ?
class arra
{
int[] q;
arra()
{
q [] = {1,2,2,4,2,2,2,2};
}
int search (int i )
{
int count = 0;
for ( int x =0; x <q.length ; x++)
if ( x == i)
count ++;
return count;
}
}
class brea{
public static void main ( String arg[])
{
arra object = new arra();
System.out.println( object.search (2));
}
}
thanks