如何根据二维数组ArrayList<Object> points
创建datapoints
?
Anothor问题:如果datapoints
是二维ArrayList,如何将第一列读入lat
,将第二列读入lon
?
public class Cluster {
private ArrayList<VisitPoint> points;
public Cluster(List[][] datapoints) {
Float lat;
Float lon;
for (int i=0; i<datapoints.length; i++) {
lat = datapoints[i][0];
lon = datapoints[i][1];
points.add(new VisitPoint(lat,lon));
}
}
public ArrayList<VisitPoint> getVisitPoints() {
return points;
}
}
答案 0 :(得分:1)
您可以使用List
的{{1}}。
ArrayList
ex iteration -
List<List<VisitPoint>> list = new ArrayList<List<VisitPoint>>();