๐Ÿš€ Day 6 of My Automation Journey โ€“ Operators in Java

Published: (February 25, 2026 at 09:32 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

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;

Assignment Operator (=)

Used to assign values to variables.

int tamil = 10;
int english = 2;

Arithmetic Operators

Used for mathematical calculations.

OperatorMeaning
+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

Unary Operators

Unary operators work on a single variable.

OperatorType
++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

Equality & Relational Operators

These operators compare two values.

OperatorMeaningExample
==Equal toa == b
!=Not equal toa != b
>Greater thana > b
=Greater than or equal toa >= b
` b); // true
System.out.println(a = b); // true
System.out.println(a 18 && age 25age 18)); // false

## Trainerโ€™s Complex Expression โ€“ Detailed Breakdown

```java
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โ€ƒโ†’ 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 the values:

result = 5 + 6 - 4 + 6 - 11 - 10

Calculation:

  • 5 + 6 = 11
  • 11 - 4 = 7
  • 7 + 6 = 13
  • 13 - 11 = 2
  • 2 - 10 = -8

Final Output: -8

What I Learned on Day 6

  • Complete understanding of Assignment, Arithmetic, Unary, Relational, and Logical operators.
  • Clear difference between == (equality) and = (assignment).
  • 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: 24/02/2026
Trainer: Nantha from Payilagam

A Small Note

I used ChatGPT to help me structure and refine this blog.

0 views
Back to Blog

Related posts

Read more ยป

#5 Known is a Drop! Operators in JAVA

Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. Simple Assignment Operator = Simple ass...