java中的运算符
算术运算符
+(加) -(减) *(乘) /(除) %(取余) ++(自增) –(自减)
注意:/(除):两个整数相除,其结果一定是整数,小数位计算机自动略去
例:
int num1 = 15; int num2 = 4; 1. int result = num1/num2; system.out.println(result); // 3 2. int result2 =num1/num2*num2; system.out.println(result2); // 12 3. double result3 = num1/num2; system.out.println(result3); // 3.0 4. double result4 =num1/num2+0.0; system.out.println(result4); //3.0 5. double result5 =num1/(num2+0.0) system.out.println(result5 ); //3.75