三元运算符


public class demo07 {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        a+=b;//a=a+b
        a-=b;//a=a-b
        System.out.println(a);
        //字符串连接符 +____;String
        System.out.println(""+a+b);//自动转换为连接符,连接a,b  //1020
        System.out.println(a+b+"");//先计算,再进行连接         //30
        System.out.println("==========");
        //三元运算符
        // x ? y : z ;
        //如果 x 为 ture ,则结果为 y ,否则结果为 z;
        int score = 50;
        String type = score<60?"不及格":"及格";//字符串类型要加英文双引号
        //必须掌握
        System.out.println(type);
    }
}