java - Error scanning invalid input -


this program needs return 'invalid input' if other row between 0-4 input, getting error:

exception in thread "main" java.util.inputmismatchexception @ java.util.scanner.throwfor(unknown source) @ java.util.scanner.next(unknown source) @ java.util.scanner.nextint(unknown source) @ java.util.scanner.nextint(unknown source) @ ass.puzzle.play(puzzle.java:147) @ ass.puzzle.main(puzzle.java:18) 

you need catch thrown exception

else if (input.equals("c")) {     system.out.println("what column? (1-4)");      try{         int column = s.nextint();         s.nextline();         if (column <= 4){             rotatecolumn(currentarr,column - 1);             print(currentarr);             b++;         }         else            system.out.println("invalid input");      }catch (inputmismatchexception ex){          system.out.println("invalid input");      } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -