Я делаю решатель лабиринтов.По какой-то причине Каждый раз, когда достигается строка, помеченная '->, выводится «Введите высоту:».Это похоже на то, что эта строка (которая не запускается, когда она достигнута) каким-то образом делает цикл метода.
private void makeMap() {
Map map; //used to convert the char array into a graph
int height; //the height of the map by user input
char[][] array; //used to store the char map
System.err.println("Enter height: ");
height = scanner.nextInt(); //gets and stores the height from the user
array = new char[height][]; //initializes the map with input height
for(int i=0; i<height; i++) { //adds row by row to the map array
System.err.print("Enter next line of map: ");
array[i] = scanner.next().toCharArray();
}
--> map = new Map(array); //initializes the map by passing the char array
graph = map.makeGraph(); //creates a graph from the char array
}
Я пометил '->', где я считаю, что моя проблема лежит.Любой код, который я поместил перед отмеченной строкой, будет выполнен, но как только эта строка будет достигнута, он возвращается к началу этого метода.Ниже приведен конструктор карты:
public Map(char[][] passMap) {
adjList = new Vertex[map.length*map[0].length];
map = passMap; //stores the passed map
}
ЛЮБАЯ ПОМОЩЬ лучше, чем помощь.Я был в этом часами.Спасибо.