0

I am trying to get my method toString to get an array from the pointArray method, via the other class but I just cant get how to do it.

public class Problem4 {

public static void main (String[] args){

    Point start = new Point();

    //instansiera värderna till start-koordinaterna
    double xKoord = 5.0; 
    double yKoord = 2.0;
    double zKoord = -5.0; 

    double [] lista;
    lista = start.pointArray(xKoord, yKoord, zKoord);
    start.toString(startArray); //this one is not working
}
}

and then the other class

class Point{
//denna är temporär
private String punkt;

public double[] pointArray(double xKoord, double yKoord, double zKoord){
    //Skapar en array till punkten
    System.out.println("Metod pointArray.");

    double[] startArray = new double [3];
    startArray[0]=xKoord;  
    startArray[1]=yKoord;  
    startArray[2]=zKoord;  

    return startArray;
}

 public String toString(double [] startArray){
    //metoden ska returnera en String som innehåller värden till x, y och z-kompontenten
    System.out.println("Metod toString.");

    System.out.println (Arrays.toString(startArray));

    //denna är temporär
    return punkt;
}
}  

So the problem is how do I get the array from method pointArray to the toString-method via the Problem4-class? :/

Clara
  • 1
  • 1
  • I have tried to use this answer, but I cant get it to work from me https://stackoverflow.com/questions/20314305/how-do-i-invoke-a-method-with-array-parameter-in-java – Clara Mar 26 '20 at 10:25

1 Answers1

0

Nevermind, I solved it.

 start.toString(lista);
Clara
  • 1
  • 1