Check out example codes for "java while loop q to quit". It will help you in understanding the concepts better.

Code Example 1

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);
    }
}

Learn ReactJs, React Native from akashmittal.com