如何从返回二维数组的方法中获取值?

时间:2011-10-04 11:02:16

标签: java

private double[][] getTimeValuePairsArray(List<Double> timeList, List<Double> valueList){
    double[][] timeValuePairs = new double[2][timeList.size()];
    for (int i = 0; i < timeList.size(); ++i) {
        timeValuePairs[0][i] = ((Double)timeList.get(i)).doubleValue();
        timeValuePairs[1][i] = ((Double)valueList.get(i)).doubleValue();
    }
    return timeValuePairs;      
}

timeListvalueListArrayList个对象,包含一些数据。

double[][] timeValuePairs1 = getTimeValuePairsArray(timeList, valueList);

//here i want to display values which is returned by the above method.

1 个答案:

答案 0 :(得分:1)

for (int i = 0; i < timeList.size(); i++) {
    System.out.println(timeValuePairs1[0][i]);
    System.out.println(timeValuePairs1[1][i]);
}

或者

for (int i = 0; i < timeValuePairs1.length; i++) {
    for (int j = 0; j < timeValuePairs1[i].length; j++) {
        System.out.print(timeValuePairs1[i][j]);
    }
}