为啥下面这段代码再输入1时,运行结果是entry而win a Car!
public class Switch_Test
{
public static void main(String args[])
throws java.io.IOException
{
int a;
System.out.println("Enter a number from 1--3:");
a=(int)System.in.read();
switch(a)
{
case 1:System.out.println("win a Car!");break;
case 2:System.out.println("picked the goat!");break;
case 3:System.out.println("get to keep your 100!");
break;
default:System.out.println("entry");
}
}
}
public class Switch_Test
{
public static void main(String args[])
throws java.io.IOException
{
int a;
System.out.println("Enter a number from 1--3:");
a=(int)System.in.read();
switch(a)
{
case 1:System.out.println("win a Car!");break;
case 2:System.out.println("picked the goat!");break;
case 3:System.out.println("get to keep your 100!");
break;
default:System.out.println("entry");
}
}
}