Created
November 26, 2013 02:59
-
-
Save BornRiot/7652831 to your computer and use it in GitHub Desktop.
A simple example of a switch statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ch5; | |
| //A simple example of the switch. | |
| public class SampleSwitch { | |
| public static void main(String[] args) { | |
| // TODO Auto-generated method stub | |
| for(int i=0; i<6; i++) | |
| switch(i) { | |
| case 0: | |
| System.out.println("i is zero."); | |
| break; | |
| case 1: | |
| System.out.println("i is one."); | |
| break; | |
| case 2: | |
| System.out.println("i is two."); | |
| break; | |
| case 3: | |
| System.out.println("i is three."); | |
| break; | |
| default: | |
| System.out.println("i is greater than 3."); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment