基本类型 | 大小(字节) | 包装类 |
---|---|---|
byte | 1 | Byte |
short | 2 | Short |
int | 4 | Integer |
long | 8 | Long |
char | 2 | Character |
float | 4 | Float |
double | 8 | Double |
boolean | - | Boolean |
自动类型转换
![](https://img.haomeiwen.com/i847270/a2ac25c252206c8d.jpg)
运算符优先级
Math类中的round、ceil、floor
round为四舍五入,ceil为向上取整, floor为向下取整。
数字 | floor | round | ceil |
---|---|---|---|
1.4 | 1.0 | 1 | 2.0 |
1.5 | 1.0 | 2 | 2.0 |
1.6 | 1.0 | 2 | 2.0 |
-1.4 | -2.0 | -1 | -1.0 |
-1.5 | -2.0 | -1 | -1.0 |
-1.6 | -2.0 | -2 | -1.0 |
网友评论