2011-09-11 112 views
0

我对Java很新,我试图编写一个在地图上显示点列表的应用程序。我有这么多的工作,现在我想找出设置缩放区域的边界。要做到这一点,我已经创建了一个包含我所有的地方对象类,扩展的ArrayList()如下:访问扩展ArrayList对象的元素

public class PlaceList extends ArrayList<Place> { 
private static final long serialVersionUID = 4374092139857L; 

public PlaceList() { 
} 

public Double getNorthernLimit() { 
    double mostNorthern; 
     for (Place curPlace: ???????) { 
     //check each place and keep most northern one 
     } 

    return mostNorthern; 
} 

我的问题是,我不知道如何访问对象的ArrayList(其中? ?是)。我想循环通过它们来确定最偏北的点。

任何帮助,将不胜感激。

回答

3

只需使用this

for (Place curPlace : this) 
{ 
} 

我会亲自避免延长ArrayList<Place>下手虽然 - 我更喜欢使用超过组成继承,所以我通常会让我的课包含一个List<Place>代替。

+0

非常感谢,认为这将是明显的东西!事后看来,这个作品确实听起来更好。 –