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. output is not specified there.., it must should be
View Tutorial          By: yash at 2014-09-17 16:35:52

2. really this introduction makes me very interesting
View Tutorial          By: Himaja Reddy at 2012-11-09 06:57:31

3. /*Web.xml File */

<?xml vers

View Tutorial          By: Pavan Barot at 2010-07-11 23:32:35

4. thanks!!
View Tutorial          By: eoko at 2011-05-10 23:34:29

5. excellent, very clear, thx!!!
View Tutorial          By: ma at 2010-04-07 07:42:47

6. hola

no funciona este
Stri

View Tutorial          By: ahmed at 2012-05-11 14:18:46

7. What is meant by source code portability?
View Tutorial          By: sathihs at 2012-11-02 11:16:57

8. Your Work is Good, But i want to ask if there is a
View Tutorial          By: Good Muyis at 2011-01-08 09:47:14

9. Thanks
muchas gracias
Excellent

View Tutorial          By: Alfredo at 2010-05-31 09:00:36

10. it's very good to understand...and it is helpful f
View Tutorial          By: Rakesh at 2009-12-26 00:14:59