算数运算符:%模(求余数),+,-,*,/,++,--
有long类型的输出都是long类型,其余都是int类型
b = a++ :先赋值,a再加1
c = ++a :先a+1 ,再赋值
赋值运算符:=
关系运算符:>,<,<=,>=,==,!=instanceof
逻辑运算符:&&,||,!(与,或,非)
与运算时,前者为false时,不运算后面的
位运算:&,|,^,~,>>,<<,>>>
<<相当于*2 ,>>相当于除以2
条件运算符?: A?B:C,A如果为真,则B,否则C
package operator;
public class Demon08 {
public static void main(String[] args) {
int score = 80;
String type = score <60 ? "不及格" : "及格";
System.out.println(type);
}
}
拓展赋值运算符:+=,-=,*=,/=
字符串连结符:+ ,String
package operator;
public class Demon07 {
public static void main(String[] args) {
int a=10;
int b = 10;
//字符串连接符 + ,String
System.out.println(""+a+b);
}
}
?
原文:https://www.cnblogs.com/ruobiliunian/p/14483398.html