Arithmetic & Assignment Operators
Operators are symbols that perform operations on variables and values. Java provides arithmetic operators for math, assignment operators for storing values, and shorthand operators for common patterns. This is a foundational concept in enterprise application development that professional developers rely on daily. The explanations below are written to be beginner-friendly while covering the depth and nuance that comes from real-world Java experience. Take your time with each section and practice the examples
35 min•By Priygop Team•Last updated: Feb 2026
Arithmetic & Assignment Operators
Example
public class Operators {
public static void main(String[] args) {
int a = 20, b = 7;
// Arithmetic Operators
System.out.println("=== Arithmetic ===");
System.out.println("a + b = " + (a + b)); // Addition: 27
System.out.println("a - b = " + (a - b)); // Subtraction: 13
System.out.println("a * b = " + (a * b)); // Multiplication: 140
System.out.println("a / b = " + (a / b)); // Division: 2
System.out.println("a % b = " + (a % b)); // Modulus (remainder): 6
// Increment & Decrement
int count = 10;
count++; // count = 11
count--; // count = 10 again
System.out.println("Count: " + count);
// Pre vs Post increment
int x = 5;
System.out.println("x++: " + x++); // Prints 5, then x becomes 6
System.out.println("++x: " + ++x); // x becomes 7, then prints 7
// Assignment Operators (shorthand)
int score = 100;
score += 10; // score = score + 10 → 110
score -= 5; // score = score - 5 → 105
score *= 2; // score = score * 2 → 210
score /= 3; // score = score / 3 → 70
score %= 8; // score = score % 8 → 6
System.out.println("Final score: " + score);
}
}Try It Yourself: Build a Calculator
Try It Yourself: Build a CalculatorJava
Java Editor
✓ ValidTab = 2 spaces
Java|22 lines|864 chars|✓ Valid syntax
UTF-8