Hi here is the code that i am trying to compile I am trying to assign p to the index 00 and want to put it in the method and print the value in class k. can someone tell me what can i do so it does that?
class j { String[][] first = new String[1][3]; first[0][0]= "p"; void method(){ System.out.println(first[0][0]);
} }
class k{ public static void main(String[] args){ j one = new j(); one.method();
} }
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
In Java, you can't have the assignment first[0][0]=p where you wrote it. It has to be within a method, a constructor etc... for example, here it is, placed in a constructor: