将二维数组读入arraylist

时间:2013-03-25 17:36:50

标签: java arrays arraylist

如何根据二维数组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;
    }

}

1 个答案:

答案 0 :(得分:1)

您可以使用List的{​​{1}}。

ArrayList

ex iteration -

List<List<VisitPoint>> list = new ArrayList<List<VisitPoint>>();