<<< While Statement Example | Index | Another Loop Example >>> |
The user controls whether to continue to execute the block of code by entering "y" or "Y":
Scanner scnr = new Scanner( System.in ); String response = "y"; while( response.equalsIgnoreCase( "y" ) ) { // several statements within the block // ... System.out.print( "Continue – Y/N?" ); response = scnr.next(); }
<<< While Statement Example | Index | Another Loop Example >>> |