SWITCH STATEMENT

 package com.cnc;


public class Main {

public static void main(String[] args) {
int switchValue = 1;

switch (switchValue){
case 1:
System.out.println("value was 1");
break;
case 2:
System.out.println("value was 2");
break;
case 3:
System.out.println("value was neither 1 nor 2");
break;
default:
System.out.println("Was not 1 or 2");
}
}
}

Both if statement and switch statement can achieve the same. 

Popular posts from this blog

NUMBER PALINDROME CHALLENGE

ENCAPSULATION CHALLENGE

USER INPUT PRINT ORIGINAL,REVERSE ARRAY AND SORTED ARRAY