3
所以我想輸入點的兩個座標到數組中。對不起,如果這是離開,我很困惑。將值輸入到點數組中?
//create array of 100 coordinate points
//Excerpt from Main
Point[] A = new Point[100];
Scanner in = new Scanner(System.in);
System.out.println("Enter index: ");
int i = in.nextInt(); //validate
System.out.print("Enter integers x, y to replace: ");
A[i].input(in);
...
public class Point {
int x, y;
Point(int x, int y) {
throw new UnsupportedOperationException("Not supported yet.");
}
void input(Scanner sc){
x = in.nextInt();
y = in.nextInt();
}
}
感謝您的回覆,但我仍然迷失。我收到了錯誤「線程中的異常」main「java.lang.UnsupportedOperationException」,我更新了帖子以添加我的Point.java。 – Joe123
沒關係,我想我明白了。謝謝 – Joe123