运算符
算术运算符:‘+’ ‘-’ ‘*’ ‘/’ ‘%’ ‘++’ ‘–’
int a=2
int b=a++;//执行完这行代码后,先给b赋值,在自增
int c=++a;//执行完这行代码前,先自增,再给c赋值
幂运算
double pow=Math.pow(2,3);//表示2的三次方
System.out.println(pow);
赋值运算符:=
关系运算符:‘>’ ‘<’ ‘>=’ ‘<=’ ‘==’ ‘!=’
(返回的结果为true或false)
逻辑运算符:‘&&’ ‘||’ ‘!’
public class study1 {
public static void main(String[] args) {
boolean a=true;
boolean b=false;
System.out.println("a&&b:"+(a&&b));
System.out.println("a||b:"+(a||b));
System.out.println("!(a&&b):"+!(a&&b));
}
}//自己观察输出结果
位运算符:‘&’ ‘|’ ‘^’ ‘~’ ‘>>’ ‘<<’ ‘>>>’
(与计算机的二进制有关,点击此处观看详情分析)
条件运算符:?:
x?y:z
//如果x==true,则结果为y,否则为z
扩展赋值运算符:‘+=’ ‘-=’ ‘/=’…
a+=b //a=a+b
a*=b //a=a*b
......
标签:Java,System,运算符,&&,println,赋值,out
From: https://blog.csdn.net/Ma_yc0725/article/details/142875322