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. I have maked all you said and when I open jsp I am
View Tutorial          By: John at 2013-01-10 14:21:30

2. hi i am shahid i have made SMS application in j2me
View Tutorial          By: shahid khan at 2012-06-18 13:19:06

3. Great example. To reset the initial value on readb
View Tutorial          By: Bala at 2014-07-22 04:48:34

4. Hi,

I have tried with your script a

View Tutorial          By: Ivan at 2011-09-08 21:17:36

5. I am using my samsung s5233 via usb connection, ru
View Tutorial          By: Puneet at 2010-04-23 06:14:28

6. hello!
I am so confused and a total beginne

View Tutorial          By: Jena at 2011-06-11 17:39:39

7. Thanks.. grt example
Also... If the type ar

View Tutorial          By: Shahid at 2011-12-20 10:26:22

8. nice intelligent work
View Tutorial          By: santosh at 2010-11-28 01:18:50

9. Thanks very much, this helped alot.
View Tutorial          By: Steve at 2012-10-09 21:09:16

10. Thank you for this useful script! It works very we
View Tutorial          By: Giuseppe at 2010-12-09 05:35:43