wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Cant compile the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cant compile the program" Watch "Cant compile the program" New topic

Cant compile the program

jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
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(){


class k{
public static void main(String[] args){
j one = new j();

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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:
jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
Thank you very much that solved the problem
I agree. Here's the link: http://aspose.com/file-tools
subject: Cant compile the program
Similar Threads
Arrays of Arrays
Array Indexing
Question on multi dimensional array
can any one explain Two -Dimensional Arrays (code)
Ambiguous Reference to method