加上main函数和类试试,如下 输出结果 : 6
public class TestSwitch {
public static void main(String[] args) {
int a=4,b =2;
char ch = '+';
switch(ch)
{
case '-':
System.out.println(a-b);
break;
case '+':
System.out.println(a+b);
break;
case '*':
System.out.println(a*b);
break;
case '/':
System.out.println(a/b);
break;
default:
System.out.println("feifa");
}
}
}
|