I am making a maze solver. For some reason Everytime the line marked with '-->' is reached, "Enter height: " is outputted. It is like that line (which is not run when it is reached) somehow makes the method loop.
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
}
I labelled with '-->' where I believe my problem lays. Any code i put before the marked line will execute, but as soon as that line is reached it loops back to the top of this method. Below is the Map constructor:
public Map(char[][] passMap) {
adjList = new Vertex[map.length*map[0].length];
map = passMap; //stores the passed map
}
ANY HELP is better than no help. I've been at this for hours. Thanks.
nextafter anextIntandnextFloat. See this topic and RD1's comment for more information: stackoverflow.com/questions/4708219/…System.err.printlnfor your output?