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. Hi,.
No Change yaar, Im still getting the s

View Tutorial          By: Dinesh Rajendiran at 2012-03-23 05:19:06

2. I am getting this error with Minecraft; Feed the B
View Tutorial          By: LadyKianna at 2013-03-11 05:52:54

3. Hi DILIP !
Can you plz help me I have an ex

View Tutorial          By: Bull at 2012-01-25 16:16:36

4. how to connect the database in servelet use to sta
View Tutorial          By: sudhir singh tomar at 2011-04-28 03:10:34

5. output is not specified there.., it must should be
View Tutorial          By: yash at 2014-09-17 16:35:52

6. Awsome...Example...
View Tutorial          By: sitakanta at 2011-12-05 12:22:03

7. hi every body i want full java code to send messag
View Tutorial          By: Ashray P Shetty at 2010-11-09 04:33:45

8. I have got "time out at step 6". How can
View Tutorial          By: MCHON at 2008-10-05 12:36:42

9. it worked fine in solving an algorithm assingment.
View Tutorial          By: tunde bello at 2009-11-05 06:31:28

10. nice article but can more example
View Tutorial          By: sandi at 2012-10-18 13:26:10