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 a sample code in which,

obje

View Tutorial          By: Tan Mi at 2011-10-25 23:24:10

2. Simpler example:

import java.io.*;

View Tutorial          By: Joseph Harner at 2011-12-04 23:20:48

3. good
View Tutorial          By: sasikiran at 2008-03-30 23:33:24

4. I have maked all you said and when I open jsp I am
View Tutorial          By: ismail at 2011-03-16 04:08:53

5. Thank you sir for your valuable guidence on garbag
View Tutorial          By: Rahul at 2011-06-13 04:40:52

6. This article is very good. It is very easy to unde
View Tutorial          By: Vandana B.Dass at 2010-02-01 00:54:54

7. i get this error too.
: Parent: child proce

View Tutorial          By: Anon at 2009-02-25 08:30:58

8. realy very nice artical it give good understable
View Tutorial          By: vivek at 2009-06-19 01:27:46

9. this is no doubt a simple program for the learner
View Tutorial          By: shweta at 2008-07-12 01:18:59

10. great resource
View Tutorial          By: Anonymous at 2011-04-14 03:14:43