|
||
|
|||
|
hi so fare i have this but it doesnt seem to be working:
in one class i have: Java Code
public class siwtchMenu{
public String[][] arrayA(int x, int y){
String arrayTest[][] = {{"0", "1", "2"},{"0","1", "2"}};
return arrayTest[x][y]; //error is here
}
}
Java Code
public class case1{
void case1(){
switchMenu obj = new switchMenu();
System.out.println("Array is:");
for(int i=0; i<3; i++){
System.out.println(obj.arrayTest[i][i]+ ", ");
}
}
}
Quote:
thanks in advance! =]
Last edited by straw; 11-03-2010 at 03:38 PM. Reason: miss type |
|
|||
|
hi thanks for the quick responce, now re the case1 error that was me just being tired and typing it out wrong i didnt do that in my actual project!
when i do as you say above it just comes up with: Quote:
![]() so how would i go about defining arrayTest as an object variable? baring in mind that i do want to edit the array latter! |
|
||||
|
OK there are two problems I can see here first of all here:
Java Code
public class siwtchMenu{
public String[][] arrayA(int x, int y){
String arrayTest[][] = {{"0", "1", "2"},{"0","1", "2"}};
return arrayTest[x][y]; //error is here
}
}
EDIT: Ah just looked at your code again and maybe I misunderstood what you are trying to do. I assumed you want the loop in case1 to run through and call the method arrayA each time to return the value contained in it. What you are trying to do here : Java Code
System.out.println(obj.arrayTest[1][1]+ ", "); Last edited by Faz; 11-03-2010 at 08:38 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Arrays.equals not returning correct answer. | Anyone | Collections and Generics | 2 | 11-02-2010 02:12 PM |
| Object array to int array? | rsala004 | Collections and Generics | 1 | 30-10-2009 08:09 AM |
| throwing and returning | chronoz13 | Exceptions | 6 | 25-10-2009 04:00 AM |
| Storing an array into an array | vluong | Collections and Generics | 4 | 22-09-2009 07:14 PM |
| Returning Random Strings from an Array | cfmonster | Collections and Generics | 3 | 09-09-2009 04:13 AM |
|
100 most searched terms
Search Cloud
|
| 2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? |