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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. hi ..........
the code is worked for me....
View Tutorial By: pradeep at 2012-01-25 06:30:14
2. If I have reliance netconnect connected to my lapt
View Tutorial By: Shaik Allabakash at 2010-02-09 19:38:10
3. i want to know more sample codes in object oriente
View Tutorial By: glades at 2013-01-23 08:28:33
4. Hi Ramlak
First of all thanks for u
View Tutorial By: Vikas sharma at 2010-05-08 01:09:31
5. thank you.
View Tutorial By: lluulnw at 2014-11-22 12:39:35
6. it is unfair to leave this portal without thanking
View Tutorial By: anil kumar at 2009-12-30 23:40:25
7. nice explanation
View Tutorial By: harish at 2012-12-04 06:20:45
8. So simple..Very easy to understand
View Tutorial By: G.Tejasree at 2011-11-05 11:51:38
9. Very nicely explained, especially the step-by-step
View Tutorial By: Kaushik at 2012-09-20 04:14:21
10. Life-saving post, man!
(In my case i had II
View Tutorial By: Julianno Jungle at 2013-06-28 18:32:03