DEV Community

Cover image for πŸš€ Day 6 of My Automation Journey – Operators in Java
bala d kaveri
bala d kaveri

Posted on • Edited on

πŸš€ Day 6 of My Automation Journey – Operators in Java

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 ;
Enter fullscreen mode Exit fullscreen mode

Here:

+ β†’ Operator
10 and 5 β†’ Operands
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 1️⃣ Assignment Operator (=)

Used to assign values to variables.

int tamil = 10;
int english = 2;
Enter fullscreen mode Exit fullscreen mode

= assigns the value to the variable.

πŸ”Ή 2️⃣ Arithmetic Operators

Used for mathematical calculations.

Operator    Meaning
+           Addition
-           Subtraction
*           Multiplication
/           Division
%           Modulus (Remainder)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 3️⃣ Unary Operators

Unary operators work on a single variable.

Operator    Type
++          Increment
--          Decrement
Enter fullscreen mode Exit fullscreen mode

πŸ”Έ 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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ”₯ Trainer’s Complex Expression – Detailed Breakdown

int a = 5;
int b = 7;
int c = 10;

int result = a++ + a-- - --a + --b - ++c - --c;
Enter fullscreen mode Exit fullscreen mode

🧠 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)