Files
javaSE-0419/day02/src/com/inmind/yunsuanfu02/Demo06.java
2026-04-23 11:34:12 +08:00

30 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.yunsuanfu02;
/*
要学习的是:
6.运算符_算术运算符+ - * / % ++(自增) --(自减)
总结:
1.算术运算时运算符前后的数据类型如果是一致,那么结果也就是该数据类型
2.算术运算时运算符前后的数据类型如果是不一致,那么结果也就是该数据类型中大范围的数据类型
有特例byteshortchar这3个类型在运算时最终的结果都是int
*/
public class Demo06 {
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计算的结果也是int是3
System.out.println(10%3);//1
System.out.println("----------------------");
System.out.println(3124/1000*1000);//3000
System.out.println(3124/1000.0*1000);//3124.0
System.out.println("----------------");
byte b = 3;
byte b1 = 1;
//byte b2 = b+b1;//有特例byteshortchar 在运算时直接提升为int计算
}
}