Почему это дает ошибку в строке treasureLocations [] = new Coord (rows, cols); концструктора?Что случилось с конструктором?
public class TreasureMap{
int rows, cols; // How big is the treasure map
Coord [] treasureLocations; // The locations of treasures
Scanner kbd = new Scanner(System.in);
// Prompt the user for info on the treasure map and then create it
// COMPLETE THIS METHOD
public TreasureMap(){
System.out.println("Enter the map size (2 ints): ");
rows = kbd.nextInt();
cols = kbd.nextInt();
treasureLocations[] = new Coord(rows, cols);
public class Coord {
public final int row;
public final int col;
// Constructor,
public Coord(int ir, int ic){
this.row = ir;
this.col = ic;
}
Здесь все неправильно. Взгляните на http://stackoverflow.com/questions/1200621/declare-array-in-java, чтобы узнать, как вам нужно создать экземпляр массива. – Nami
Пожалуйста, правильно отформатируйте свой код! Он даже не компилируется. – isnot2bad
'arrayName [] = anything;' недопустимый синтаксис в Java. – Shashank