1. Member Join Date
Jan 2011
Posts
21
Rep Power
0

## returning double array

i am trying to create something that will show the center Y positions on a label depending on the amount of lines needed and the text height. I have all the equations and such but is there a way to return a double array. this is what i have now:
Java Code:
```import java.util.Scanner;

public class XYCalc
{
public static double[] calcY(double lines, double textHeight, double labelHeight)
{
double k = labelHeight / lines;
double l = k / 2;
double y = l - (textHeight / 2);
double o[] = {2, 9};
return o;
}
public static void main(String [] args)
{
double lines;
double textHeight;
double labelHeight;
Scanner input = new Scanner(System.in);

System.out.println("Amount of lines: ");
lines = input.nextDouble();
System.out.println("Height of text: ");
textHeight = input.nextDouble();
System.out.println("Height of label: ");
labelHeight = input.nextDouble();
input.close();

double y[] = calcY(lines, textHeight, labelHeight);

System.out.println("Y: " + y);
}
}```
and i get this:
Java Code:
```Amount of lines:
2
Height of text:
.5
Height of label:
2
Y: [D@14318bb

Process completed.```
I would like to be able to read it haha.  Reply With Quote

2. ## You're getting the default toString() representation of a double array. To show the array elements, either use a for loop to iterate through the array printing as you go, or use java.util.Arrays.toString(myArray) to convert the array to String for display.  Reply With Quote

3. Member Join Date
Jan 2011
Posts
21
Rep Power
0

## Thanks so much! I am fairly new to all this so I really do appreciate it.  Reply With Quote

double array, return 