Changin type int to type double.. Java

Thread Starter

Ben_C

Joined Oct 19, 2010
65
Ive got some code that is int but needs to be double as I need it to have values to 1 decimal place.. I've simply changed it to double where it says int but when i compile it it gives an error saying:
found: double
expected: int

:S

Well confused.

Rich (BB code):
int firstarray[][] = {{a,b,c},{d,e,f},{g,h,i}};
 System.out.println("The readings are");
 display(firstarray);
 }
 public static void display (int x[][]){
   for (int row=0;row<x.length;row++){
      for (int column=0;column<x[row].length;column++){
 
  System.out.print (x[row][column]+"\t");
 }
  System.out.println();
Ive changed it to:

Rich (BB code):
double firstarray[][] = {{a,b,c},{d,e,f},{g,h,i}};
 System.out.println("The readings are");
 display(firstarray);
 }
 public static void display (double x[][]){
   for (double row=0;row<x.length;row++){
      for (double column=0;column<x[row].length;column++){

 System.out.print (x[row][column]+"\t");
 }
 System.out.println();
But this give me the error... All the other code (double) compiles up until this point, i just cant figure it out.
Help?
 
Last edited:

Thread Starter

Ben_C

Joined Oct 19, 2010
65
Im a genius ive done it haha, heres how..

Rich (BB code):
double firstarray[][] = {{a,b,c},{d,e,f},{g,h,i}};
 System.out.println("The readings are");
 display(firstarray);
 }
 public static void display (double firstarray[][]){
   for (int row=0;row<firstarray.length;row++){
      for (int column=0;column<firstarray[row].length;column++){

 System.out.print (firstarray[row][column]+"\t");
 }
 System.out.println();
 
Top