一.运算符
1.算术运算符
+ - * / % ++ --
public class Test7 { public static void main(String[] args) { int x = 10; int y = 3; float f = 3.5f; System.out.println(x/y); // 3 System.out.println(x%y); // 1 System.out.println(x/f); // 2.857143 x隐式转换成float System.out.println(x%f); // 3.0 y++; System.out.println(y); // 4 y--; System.out.println(y); // 3 } }
2.赋值运算符
= += -= *= /=
3.关系运算符
> < >= <= ==
4.逻辑运算符
& | ! ^ && ||
5.位运算符
<< >>
6.三目运算符
?:
二.运算符的优先级
三.表达式
运算符与操作数的结合
时间: 2025-01-02 14:05:18