1
I would like to know how I do to redo the instruction of a method until the user cancels.
I have the following method, for example:
public static void method(){
int i = 1;
i += 1;
String choise;
println("Exit?");
choise = scan.next();
if(choise.equals("y")){
System.Exit(0);
} else if(choise.equals("n")){
/* ???? */
} else{
...
}
}
I imagine I could use a loop, while for example, and run the instruction until Choise is "n". But I would like to know if it was possible to do it differently without using a loop.
There are many alternatives. What is the action to have is against action?
– Jefferson Quesado
So. The idea is that whenever the user type "N" he redoes i += 1; assuming the state of the variable is 1.
– Lucas