Skip to content
This repository has been archived by the owner on Jan 1, 2019. It is now read-only.

Commit

Permalink
Create SwitchExample.groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
haggcoder authored Oct 4, 2017
1 parent 061dbab commit 68ce578
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Groovy/DecisionControl/SwitchExample.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class Example {
static void main(String[] args) {
//initializing a local variable
int a = 2

//Evaluating the expression value
switch(a) {
//There is case statement defined for 4 cases
// Each case statement section has a break condition to exit the loop

case 1:
println("The value of a is One");
break;
case 2:
println("The value of a is Two");
break;
case 3:
println("The value of a is Three");
break;
case 4:
println("The value of a is Four");
break;
default:
println("The value is unknown");
break;
}
}
}

/*
Output: The value of a is Two
*/

0 comments on commit 68ce578

Please sign in to comment.