aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cant compile the program" Watch "Cant compile the program" New topic
Author

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(){
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
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
can any one explain Two -Dimensional Arrays (code)
Arrays of Arrays
Question on multi dimensional array
Array Indexing
Ambiguous Reference to method