I've heard that you can use switch on strings, but Im not getting it to work. ToDo would in this case be a user input String, but my compiler tells me "int cannot be converted into String". Can anybody tell me what I'm doing wrong?
class Comands {
public Comands () {}
public void doSomething (String toDo){
while (!(toDo.equals("quit"))) {
switch (toDo) {
case 1: toDo.equals("right");
System.out.println("go right");
break;
case 2: toDo.equals("left");
System.out.println("go left");
break;
}
}
}
}
case "right": System.out.println("go right"); break; case "left":...