Java switch操作符

2019年2月12日22:02:44 发表评论 1,076 views
/**
 * Created by xabcd on 2019/2/12.
 */
public class TestJava_switch
{public static void main(String args[])
{
    int a = 100,b=7;
    char oper = '*';
    switch(oper)
    {
        case '+':
            System.out.println("a+b"+(a+b));
            break;
        case '/':
            System.out.println("a/b"+(a/b));
            break;
        case '-':
            System.out.println("a-b"+(a-b));
            break;
        case '*':
            System.out.println("a*b"+a*b);
            break;
        default:
            System.out.println("未知操作!");
    }
}
}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: