Source code for SwitchExample2.java:

public class SwitchExample2
{
	public static void main(String args[])
	{
		// SwitchExample2
		char choice = 'c';
		switch (choice)
		{
			case 'a':
				System.out.println("alpha");
				break;
			case 'b':
				System.out.println("beta");
				break;
			case 'c':
				System.out.println("charlie");
				break;
			default:
				System.out.println("Unknown");
		}
	}
}

Output from SwitchExample2.java:

charlie

--- Output Ends ---

NOTE:

You are reading previously generated output. You are not currently running the SwitchExample2 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