Comment on Tutorial - The switch Statement example in Java By Kamini



Comment Added by : srinath

Comment Added at : 2013-04-28 10:17:24

Comment on Tutorial : The switch Statement example in Java By Kamini
import java.util.Scanner;
public class SwitchDemo {
public static void main(String[] args) {

Scanner d=new Scanner(System.in);
int month=d.nextInt();
String monthString;
switch (month) {
case 1: monthString = "January";
break;
case 2: monthString = "February";
break;
case 3: monthString = "March";
break;
case 4: monthString = "April";
break;
case 5: monthString = "May";
break;
case 6: monthString = "June";
break;
case 7: monthString = "July";
break;
case 8: monthString = "August";
break;
case 9: monthString = "September";
break;
case 10: monthString = "October";
break;
case 11: monthString = "November";
break;
case 12: monthString = "December";
break;
default: monthString = "Invalid month";
break;
}
System.out.println(monthString);
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. when i tried this code i couldnt run the program..
View Tutorial          By: kavitha at 2009-11-28 01:38:55

2. How do I insert an image in a list? I am using Vis
View Tutorial          By: anu at 2010-04-16 03:07:00

3. had the sample problem.. java.io.IOException: HTTP
View Tutorial          By: java at 2012-08-22 09:39:57

4. i m very glad to know and use this site. this is w
View Tutorial          By: Rupinder at 2009-09-08 08:49:23

5. please gave us simple difference between structure
View Tutorial          By: vishal at 2011-12-18 13:33:17

6. You said the garbage collector can not be forced,
View Tutorial          By: Biniam E at 2011-12-17 15:09:09

7. Very helpful.
View Tutorial          By: Krishna at 2012-06-14 10:25:00

8. i want to fetch some rows from database using ESQL
View Tutorial          By: anonymous at 2013-03-14 14:17:19

9. Thanks so much useful to me.
View Tutorial          By: Bhuvan at 2012-05-31 14:57:57

10. hi and thanks for this good example , i want ask i
View Tutorial          By: Maryam at 2011-12-17 11:19:07