arraylist를 만들었습니다.ArrayList에 저장된 객체에 액세스 할 수 없습니다.
List FWD = new ArrayList<Coords>();
FWD.add(new Coords(42.41, 37.23));
FWD.add(new Coords(37.09, 47.8));
FWD.add(new Coords(36.83, 48.42));
후, 나는 이런 식으로리스트의 각 요소에 액세스하려면 :
FWD.get(3).[some method from Coords class]
를하지만, 넷빈즈는 말한다 :
기호 기호를 찾을 수 없습니다 : 방법 getIndexX() 위치 : 클래스 오브젝트
코드 클래스 :
public class Coords {
private double weightY, indexX;
Coords(double x, double y){
setIndexX(x);
setWeightY(y);
}
public double getWeightY() {
return weightY;
}
public void setWeightY(double weightY) {
this.weightY = weightY;
}
public double getIndexX() {
return indexX;
}
public void setIndexX(double indexX) {
this.indexX = indexX;
}
}
'목록 FWD = 새로운 ArrayList를 ()를 사용해야합니다. 또한 배열은 0 개의 기본 인덱스를 가지므로리스트의 마지막 요소를 얻으려면'FWD.get (2);'이어야합니다. –