Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 674 Bytes

12. Operators ( Arithmetic ).md

File metadata and controls

26 lines (22 loc) · 674 Bytes

12. Operators ( Arithmetic )

The operands of the arithmetic operators must be of a numeric type. you can also use them on char types, since it is a subset of int int java.

Operator Operation
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ increment
+= Addition assignment
-= Subtraction assignment
*= Multiplication assignment
/= Division assignment
%= Modulus assignment
- - Decrement

The modulus operator preserves the sign of the dividend.

system.out.println(8 % 3); // 2
system.out.println(8 % -3); // 2
system.out.println(-8 % 3); // -2