Learn Java Tutorial for Beginners (Video), Part 9: Switch

How to use the switch statement in Java; a construct that many programmers neglect but that invariably appears early on in tests and courses!

When the video is running, click the maximize button in the lower-right-hand corner to make it full screen.

Code for this tutorial:

import java.util.Scanner;

public class Application {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        System.out.println("Please enter a command: ");
        String text = input.nextLine();

        switch (text) {
        case "start":
            System.out.println("Machine started!");

        case "stop":
            System.out.println("Machine stopped.");

            System.out.println("Command not recognized");