package operator; import com.sun.media.jfxmediaimpl.HostUtils; public class Demo01 { public static void main(String[] args) { int a = 10; int b = 10; a+=b;//a = a+b a-=b;//a = a-b System.out.println(a); //字符连接符 + ,有String类型的时候会将+改成字符连接号 System.out.println(a+b); System.out.println(""+a+b);//字符在前会将后面的a+b变成字符链接 System.out.println(a+b+"");//a+b在前会先进行加减运算 } }
package operator; public class Demo2 { public static void main(String[] args) { //条件运算符 //x ? y : z //如果x==true,则结果为y,否则结果为z int scoer = 50; String type = scoer <60 ? "不及格":"及格"; System.out.println(type); } }