I would like to know how I can 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 while loop, for example, and execute the statement until choise is "n". But I would like to know if it was possible to do this otherwise without using a loop.