Skip to content

Instantly share code, notes, and snippets.

@BornRiot
Created November 26, 2013 02:59
Show Gist options
  • Save BornRiot/7652831 to your computer and use it in GitHub Desktop.
Save BornRiot/7652831 to your computer and use it in GitHub Desktop.
A simple example of a switch statement.
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