Journey to Java: Episode 5 “Control Flow”

Switch

int value = 1;switch(value) {
case 1:
System,out.println("value was 1");
break;
}

For

for(init; termination; increment) {}
for(int i = 0; i < 5; i++) {
System.out.println("i = " + i);
}

While

int count = 0;
while(count != 5) {
System.out.println("count is " + count);
count++;
}

Do While

int count = 0;
do {
System.out.println(count);
count++;
} while (count != 5);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store