I am trying to pass 2 arrays I've created in this class, xArray[] and yArray[], to another class:
public class RungeCalculation {
private double x;
private double F1;
private double F2;
private double F3;
private double F4;
double[] xArray;
double[] yArray;
public void solve(double y, double h, int j, double i) {
xArray = new double[j];
yArray = new double[j];
// code left out
xArray[dex] = x;
yArray[dex] = y;
x = x + h;
}
private double f(double x, double y, double i){
return i;
}
}
How can I pass the arrays from the RungeCalculation
class into the RungeResult
class shown below and run them through the loops: (x and y are JTexArea)?
public class RungeResult extends JFrame {
RungeResult() {
// code left out
for(int i = 0; i < xArray.length; i++) {
x.append(" " + Double.toString(xArray[i]) + "\n");
}
for(int i = 0; i < yArray.length; i++) {
y.append(" " + Double.toString(yArray[i]) + "\n");
}
}
}
I tried to make to function that called the arrays, and making them global and neither seemed to work.
double[] xArr() {
return xArray;
}
double[] yArr() {
return yArray;
}
and calling them in the other class:
double[] xArray = Arrays.xArr();
double[] yArray = Arrays.yArr();
Which did not seem to work out.