Source code for SwitchExample1.java:

public class SwitchExample1
{
	public static void main(String args[])
	{
		// SwitchExample1
		int choice = 1;
		switch (choice)
		{
			case 0:
				System.out.println("Zero");
				break;
			case 1:
				System.out.println("One");
				break;
			case 2:
				System.out.println("Two");
				break;
			default:
				System.out.println("Unknown");
		}
	}
}

Output from SwitchExample1.java:

One

--- Output Ends ---

NOTE:

You are reading previously generated output. You are not currently running the SwitchExample1 application at the momement. You need to compile and run the source code first.

To run this program:


Authors: Kevin Chu and Eric Brower
Copyright 2000 Prentice Hall PTR