Java Scanner loop? -


i making maze solver. reason everytime line marked '-->' reached, "enter height: " outputted. line (which not run when reached) somehow makes method loop.

private void makemap() {     map map; //used convert char array graph     int height; //the height of map user input     char[][] array; //used store char map      system.err.println("enter height: ");     height = scanner.nextint(); //gets , stores height user      array = new char[height][]; //initializes map input height     for(int i=0; i<height; i++) { //adds row row map array         system.err.print("enter next line of map: ");         array[i] = scanner.next().tochararray();     }      --> map = new map(array); //initializes map passing char array      graph = map.makegraph(); //creates graph char array   } 

i labelled '-->' believe problem lays. code put before marked line execute, line reached loops top of method. below map constructor:

public map(char[][] passmap) {     adjlist = new vertex[map.length*map[0].length];     map = passmap; //stores passed map } 

any better no help. i've been @ hours. thanks.

your map variable uninitialized. change:

adjlist = new vertex[map.length*map[0].length]; 

to:

adjlist = new vertex[passmap.length*passmap[0].length]; 

i change system.err.println() calls system.out.println(). first 1 error output, , second 1 normal console output.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -