October 2017
Beginner
318 pages
7h 26m
English
What if instead of checking our conditional at the beginning of our loop, we check it at the end? This is in fact an option. The do...while loops operate just like while loops, but the first time they run, they won't check to see whether a conditional is true; they'll simply run through and check their conditional statement at the end. We do need to put a semicolon at the end of a conditional statement on the back of the do...while loop. I just mentioned this because I always forget it. Now, if we run our program, we can give any number of strings and then type in the STOP string to see everything we've typed so far and printed out to the screen:
public static void main(String[] args) { Scanner reader = new Scanner(System.in); ...Read now
Unlock full access