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
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. thank u it hlep me a lot gr8.
View Tutorial By: harish at 2012-03-31 14:34:50
2. i see that lots of people get this exception : jav
View Tutorial By: oded at 2008-09-28 03:33:33
3. Very good.
But is this (Accessor functions
View Tutorial By: peter at 2011-07-20 13:13:44
4. Hi every body.. I accomplished the task of sending
View Tutorial By: Ashray P Shetty at 2010-11-18 06:25:54
5. it was very good explanation hope all links give s
View Tutorial By: ravi at 2010-08-26 10:19:48
6. This tutorial is so simple, often we dont need to
View Tutorial By: NIrjhar at 2011-12-12 03:29:52
7. Thanks for the article. I got some clearance now.
View Tutorial By: Reddy at 2008-03-15 00:02:17
8. Try this code:
Public Class
View Tutorial By: Eldan at 2012-06-17 08:25:09
9. Even i got d same error. can u plz tell me where t
View Tutorial By: Priya at 2011-03-14 12:16:54
10. Thanks a lot Ramlak! This is still very useful af
View Tutorial By: Jacky at 2009-08-08 23:49:12