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;
}
timeList
和valueList
是ArrayList
个对象,包含一些数据。
double[][] timeValuePairs1 = getTimeValuePairsArray(timeList, valueList);
//here i want to display values which is returned by the above method.
答案 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]);
}
}