java - Why does my switch statement generates IOException -


i have switch statement:

public player player(colour colour, scotlandyardview view, string mapfilename) {     switch (typemap.get(colour)) {         case ai:             return new randomplayer(view, mapfilename);         case gui:             return gui(view);         default:             return new randomplayer(view, mapfilename);     } } 

i unhandled ioexception error. why , how fix it?

well, let me @ least answer why-part, in addition codegasmer's answer: because of methods call throws ioexception. typemap.get() (which not expect in case, threoretically possible), 'gui' method or constructor of randomplayer.

codegasmer shows way identify, of these methods responsible, see in stack trace - , reveal in of methods method in question called exception thrown.

if can live catching exception , providing fallback solution, (e. g. creating fallback object in catch block). better find out, original cause of exception , avoid it, if possible. using debugger can here much. not know details of involved classes, cannot provide further here.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -