Prince of Persia Prince of Persia - 29 days ago 7
Java Question

How to create a copy and return its object without using clone?

i was wondering how to create a copy and return its object without using the clone function.

public double[] Mean(double[][] data) {

double[] x = data[0].clone();

Answer
public double[] colMean(double[][] data) {
    double[] x = new double[data[0].length];
    for (int i = 0; i < x.length; i++) {
        x[i] = data[0][i];
    }
    return x;
}

Odd that you only want to copy data[0] though, but whatever...