File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android 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
It is sorta covered in the JavaRanch Style Guide.
subject: Cant compile the program
Similar Threads
Ambiguous Reference to method
Arrays of Arrays
Array Indexing
Question on multi dimensional array
can any one explain Two -Dimensional Arrays (code)