集册 Java实例教程 Java中的算术运算符列表

Java中的算术运算符列表

欢马劈雪     最近更新时间:2020-01-02 10:19:05

434
Operators DescriptionType Usage Result
+ Addition Binary2 + 5 7
- SubtractionBinary5 - 2 3
+ Unary plus Unary +5 Positive five. Same as 5
- Unary minusUnary -5 Negative of five
* Multiplication Binary5 * 3 15
/ Division Binary5 / 2 2
% ModulusBinary5 % 3 2
++ Increment Unary num++ Evaluates to the value of num, increments num by 1.
-- Decrement Unary num-- Evaluates to the value of num, decrements num by 1.
+= Arithmetic compound-assignment Binarynum += 5Adds 5 to the value of num and assigns the result to num.
-= Arithmetic compound assignment Binarynum -= 3Subtracts 3 from the value of num and assigns the result to num.
*= Arithmetic compound assignment Binarynum *= 15 Multiplies 15 to the value of num and assigns the result to num.
/= Arithmetic compound assignment Binarynum /= 5Divides the value of num by 5 and assigns the result to num.
%= Arithmetic compound assignment Binarynum %= 5Calculates the remainder of num divided by 5 and assigns the result to num.
展开阅读全文