On Day 6 of my Automation Journey, I explored one of the most important fundamentals in Java β Operators.
Operators are used in almost every program. Whether we are assigning values, performing calculations, comparing data, or making decisions, operators make it possible.
Todayβs learning covered:
Assignment Operators
Arithmetic Operators
Unary Operators
Equality & Relational Operators
Logical (Conditional) Operators
πΉ What is an Operator?
An operator is a special symbol used to perform operations on variables and values.
Operator β Symbol
Operand β The value on which the operator acts
Example:
int total = 10 + 5 ;
Here:
+ β Operator
10 and 5 β Operands
πΉ 1οΈβ£ Assignment Operator (=)
Used to assign values to variables.
int tamil = 10;
int english = 2;
= assigns the value to the variable.
πΉ 2οΈβ£ Arithmetic Operators
Used for mathematical calculations.
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (Remainder)
Example:
System.out.println(tamil + english); // 12
System.out.println(tamil - english); // 8
System.out.println(tamil * english); // 20
System.out.println(tamil / english); // 5
System.out.println(tamil % english); // 0
πΉ 3οΈβ£ Unary Operators
Unary operators work on a single variable.
Operator Type
++ Increment
-- Decrement
πΈ Post Increment β age++
Uses the value first, then increments.
πΈ Pre Increment β ++age
Increments first, then uses the value.
Example:
int age = 10;
System.out.println(age++); // 10
System.out.println(age); // 11
System.out.println(--age); // 10
πΉ 4οΈβ£ Equality & Relational Operators
These operators are used to compare two values.
Operator Meaning Example
== Equal to a == b
!= Not equal to a != b
> Greater than a > b
< Less than a < b
>= Greater than or equal to a >= b
<= Less than or equal to a <= b
Example:
int a = 10;
int b = 5;
System.out.println(a == b); // false
System.out.println(a != b); // true
System.out.println(a > b); // true
System.out.println(a < b); // false
System.out.println(a >= b); // true
System.out.println(a <= b); // false
These operators are mostly used in if conditions and loops.
πΉ 5οΈβ£ Logical (Conditional) Operators
&& β Both must be true
|| β At least one must be true
! β Reverses the condition
Java uses short-circuit evaluation
Logical operators always return boolean
Example:
int age = 20;
System.out.println(age > 18 && age < 30); // true
System.out.println(age > 25 || age < 30); // true
System.out.println(!(age > 18)); // false
π₯ Trainerβs Complex Expression β Detailed Breakdown
int a = 5;
int b = 7;
int c = 10;
int result = a++ + a-- - --a + --b - ++c - --c;
π§ Initial Values
a = 5
b = 7
c = 10
Step-by-Step Evaluation (Left to Right)
1οΈβ£ a++
Uses 5 β then a becomes 6
2οΈβ£ a--
Uses 6 β then a becomes 5
3οΈβ£ --a
Decreases first β a becomes 4 β uses 4
4οΈβ£ --b
b becomes 6 β uses 6
5οΈβ£ ++c
c becomes 11 β uses 11
6οΈβ£ --c
c becomes 10 β uses 10
Substituting Values
= 5 + 6 - 4 + 6 - 11 - 10
Now calculate:
5 + 6 = 11
11 - 4 = 7
7 + 6 = 13
13 - 11 = 2
2 - 10 = -8
β
Final Output
Answer is -8
π― What I Learned on Day 6
Complete understanding of Assignment, Arithmetic, Unary, Relational, and Logical operators
Clear difference between == and =
How Java evaluates pre and post increment operations
Why complex unary expressions should be written carefully
Day 6 strengthened my understanding of how Java handles values internally and how operators influence program behavior.
Date: 25/02/2026
Trainer: Nantha from Payilagam
π€ A Small Note
I used ChatGPT to help me structure and refine this blog.

Top comments (0)