Files
javaSE251223/day02/src/com/inmind/Demo05.java
2025-12-23 16:30:44 +08:00

34 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind;
/*
算数运算符包括:
+ 加法运算,字符串连接运算
- 减法运算
* 乘法运算
/ 除法运算
% 取模运算,两个数字相除取余数
++ 、 -- 自增自减运算
总结:
1.算术运算时运算符前后的数据类型如果是一致,那么结果也就是该数据类型
2.算术运算时运算符前后的数据类型如果是不一致,那么结果也就是该数据类型中大范围的数据类型
有特例byteshortchar这3个类型在运算时最终的结果都是int
*/
public class Demo05 {
public static void main(String[] args) {
System.out.println(1+3);//4
System.out.println(1-3);//-2
System.out.println(1*3);//3
System.out.println(10/3);//3 int
System.out.println(10%3);//1
System.out.println("-----------------------");
System.out.println(3124/1000*1000);//3000 0
System.out.println(3124/1000.0*1000);//3124 3124 3124.0
System.out.println("------------------------");
/*byte b = 10;
byte b1 = 20;
byte sum = b+b1;*/
}
}