Table of Contents

Understanding Operators, Operands, and Expressions

Understanding Operators

Operators are special symbols that perform operations on variables and values, known as operands. For instance, in the arithmetic operation 5 + 3, 5 and 3 are operands, while + is the operator.

Understanding Operands

Operands are the entities on which operators act to perform various tasks. In an expression like 5 * 4, both 5 and 4 serve as operands to the multiplication operator *.

What is an Expression?

An expression combines operands and operators to produce a result. For example, the expression a + b - c involves operands (a, b, c) and operators (+, -) and yields a result upon evaluation.

Key Operator in Java

1. Arithmetic Operators

2. Assignment Operators

3. Unary Operators

4. Comparison Operators

5. Logical Operators

6. Bitwise Operators


Arithmetic, Assignment, and Unary Operators

Addition and Subtraction

int num1 = 9;
int num2 = 5;

// Addition
int addResult = num1 + num2; // Result: 14

// Subtraction
int subResult = num1 - num2; // Result: 4