Chapter 3: Program Statements More Notes
While Statement:
while ( condition ) { // statements block }
A common mistake: an infinite loop. The loop will keep going forever.
The do loop:
do { // statements block } while ( condition );
The for loop:
for ( initialization; condition; update ) { // block statements }
It is a sign of unbelievably bad taste to put unrelated conditions into the loop. ( lol )
The switch statement
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
Class work:
Write a program HollePrinter_YI.java that switches the letters “e” and “o” in a string. Use the replace method repeatedly. Demonstrate that the string “Hello, World!” turns into “Holle, Werld!”