Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Switch Statement - orphaned case

843789Aug 7 2009 — edited Aug 20 2009
Hello All

Could anyone explain why i get orphaned case when compiling ? ive never seen it before ?

After some searching all i could find was to remove ;
from Switch(input);
Any ideas ? thankyou




import java.util.*;
public class Menu
{
public static void main (String[] args)
{
Scanner kybd = new Scanner (System.in);
System.out.println ("Please Chose from 1-4");

System.out.println("1.			Good Morning");
System.out.println("2.			Good Afternoon");
System.out.println("3.			Good Evening");
System.out.println("4.			Exit");


int input = 0;

do
{
input = kybd.nextInt();

Switch(input);

{

case 1:System.out.println("Good Morning");
	break;
case 2:System.out.println("Good Afternoon");
	break;
case 3:System.out.println("Good Evening");
	break;
case 4:System.out.println("Exit");
	System.exit(4);
	break;
}
}
while (input !=4);
}}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2009
Added on Aug 7 2009
162 comments
1,883 views