Basic Arithmetic Operations in Java


Java supports all basic arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), and modulus (%). These can be used with variables or literal values.

Source Code

int sum = 10 + 5; // Addition
int difference = 10 - 5; // Subtraction
int product = 10 * 5; // Multiplication
int quotient = 10 / 5; // Division
int remainder = 10 % 5; // Modulus

Use arithmetic operations to manipulate numeric data. Remember, division by zero in integer arithmetic throws an ArithmeticException.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments