how to break while loop java code example
Example 1: java while loop break
while (true) {
....
if (obj == null) {
break;
}
....
}
Example 2: java while loop q to quit
while(!choice.equals("q")){
System.out.println("Enter a number or q to quit");
choice = input.next();
if(!choice.equals("q")){
int number = Integer.parseInt(choice);
}
}