2011-09-11 113 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

非常感謝,認爲這將是明顯的東西!事後看來,這個作品確實聽起來更好。 –