5:13 am - Wednesday September 26, 2018

Java Example Program to exaplain Switch case statement

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/*java example program to explain switch case statement
*/

/**
@author:candidjava.com
@description:java example program to explain switch case statement
*/

public class SwitchCase
{
public static void main(String args[])
{
int day=7;
String dayString;
switch(day)
{
case 1:
dayString="Sunday";
break;

case 2:
dayString="Monday";
break;

case 3:
dayString="Tuesday";
break;

case 4:
dayString="Wednesday";
break;

case 5:
dayString="Thursday";
break;

case 6:
dayString="Friday";
break;

case 7:
dayString="Saturday";
break;

default: dayString = "Invalid day";
                     break;
        }
        System.out.println(dayString);

}
}

output:
Saturday

Filed in: Z-A All Java Codes

Comments are closed.