Category
Q. Switch Case in Java
 
 


Answer :
public class SwitcCasehDemo {
public static void main(String[] args) {

int month = 5;
String monthName;
switch (month) {
case 1: monthName= "Jan";
break;
case 2: monthName= "Feb";
break;
case 3: monthString = "March";
break;
case 4: monthString = "April";
break;
case 5: monthName= "May";
break;
case 6: monthName= "June";
break;
case 7: monthName = "July";
break;
case 8: monthName = "August";
break;
case 9: monthName = "Sept";
break;
case 10: monthName = "Oct";
break;
case 11: monthName = "Nov";
break;
case 12: monthName = "Dec";
break;
default: monthName = "Invalid month";
break;
}
System.out.println(monthName);
}
}
Posted By : aman
Post Answer :  
Answer * :
Are You? Already Member New User
   
User Name / Email * :
Password * :
Security Code * :

(Enter security code above shown on image)