I input the character.The code goes into an infinite loop even though it is supposed(by me i admit) not to!
The problem is that the comparison fails,because even though i typed w the loop starts again.static char getInput() { boolean error = false; char c='n'; do { try { error = false; Scanner in = new Scanner(System.in); String s; do{ s = in.nextLine(); c=s.charAt(0); }while( c!='w' ||c!='W'||c!='a'||c!='A'||c!='a'||c!='s'||c!='S'||c!='d'|| c!='D'); } catch (InputMismatchException e) { System.err.println("Unexpected IO ERROR: " + e.toString()); error = true; } } while (error); return c; }
What i wanted to do is to get input from the user by the little arrows that are placed below the big enter of the keyboard,but i do not know how to do this(the only think that comes to mind is event on GUI,but i do not want to include GUI now).