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. sir,
When I run the above code and give 6 o

View Tutorial          By: nishant at 2012-07-01 17:11:20

2. Hello,

I've got javax.comm and fol

View Tutorial          By: Ashkan at 2009-12-19 21:51:19

3. Thanks for the post !
View Tutorial          By: percy at 2011-11-24 08:56:23

4. You are using "this" to start to the thr
View Tutorial          By: sumit at 2014-10-30 08:14:55

5. i've run d program and its works
View Tutorial          By: okeaghala nneka at 2012-03-31 10:58:13

6. frnds i want serial communication over beaglebone
View Tutorial          By: Rajneesh at 2015-04-12 11:23:16

7. Dude, u xplaining lyk u already telling pros!Pls t
View Tutorial          By: Brianjambo at 2009-04-14 06:32:13

8. How could i read a file from my ftp server . sugge
View Tutorial          By: Dinshaw at 2015-02-06 07:22:03

9. Nice explaination of constructor and destructor. B
View Tutorial          By: Anon at 2009-03-01 03:50:06

10. This is very useful article with clear understandi
View Tutorial          By: Manu Manker at 2014-03-14 05:49:26