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. excellent code.....
View Tutorial          By: Anonymous at 2009-05-07 03:09:01

2. I've tried this code but i am gettting error at li
View Tutorial          By: Iqra at 2012-12-13 10:43:12

3. i Want the Flow Chart and code for the mobile Cale
View Tutorial          By: Sudip Khatiwara at 2010-03-15 04:10:41

4. through this i understand functional overloading e
View Tutorial          By: mahwash at 2012-09-19 15:29:21

5. hey guys the talk waz about main
hey man w

View Tutorial          By: shivam at 2011-07-09 11:45:54

6. well done!!nice work
View Tutorial          By: Dxy at 2010-07-26 00:46:55

7. Very nice article. Really liked the way it took me
View Tutorial          By: Sandeep at 2010-01-10 09:58:25

8. cout<<5+"object orinted programming
View Tutorial          By: SANDEEP SHARMA at 2011-09-18 19:06:57

9. hi i am studying java course.i am new to java, ple
View Tutorial          By: Rajeshkumar at 2011-11-14 08:30:29

10. please give some examples of postfix and infix.
View Tutorial          By: john mark at 2012-10-07 13:55:04