DEV Community

Cover image for 🚀 Day 3 of My Automation Journey – Data Types, Memory & Variables in Java
bala d kaveri
bala d kaveri

Posted on • Edited on

🚀 Day 3 of My Automation Journey – Data Types, Memory & Variables in Java

On Day 3, we went deeper into:

JRE inside JVM
JVM and OS independence
Data Types
Memory concepts (Stack)
Variables & memory allocation

This was a very important foundation day.

🔁 JVM and OS Independence

We learned that:

JVM makes Java platform independent

Java programs can run on Windows, Linux, or Mac

Only JVM needs to be installed for that OS

That’s why Java is called:

“Write Once, Run Anywhere”

*🔹 1. Overview *
When you write Java code, several components work together to compile and run it:

JDK → Development kit (for developers)
JRE → Runtime environment (to run Java programs)
JVM → Engine that executes Java bytecode
JIT → Performance booster inside JVM
🔹 2. Detailed Explanation
✅ JDK (Java Development Kit)
It is the full package for developers
Contains:
Compiler (javac)
JRE
Debugging tools

Used to develop, compile, and run Java programs

👉 Think: “I want to create Java programs” → You need JDK

✅ JRE (Java Runtime Environment)
It provides the environment to run Java programs
Contains:
JVM
Core libraries (like java.lang, java.util)

Does NOT include compiler

👉 Think: “I only want to run Java programs” → JRE is enough

✅ JVM (Java Virtual Machine)
It is the engine that runs Java bytecode
Converts bytecode → machine code
Platform-dependent (different JVM for Windows, Linux, etc.)

👉 Key role:

Memory management
Garbage collection
Security

👉 Think: “Executor of Java code”

✅ JIT (Just-In-Time Compiler)
It is a part of JVM
Improves performance by:
Converting bytecode → native machine code at runtime
Avoids repeated interpretation

👉 Think: “Optimizer inside JVM”

| Component | Full Form                | Purpose                               | Contains               | Independent?      | Used By    |
| --------- | ------------------------ | ------------------------------------- | ---------------------- | ----------------- | ---------- |
| **JDK**   | Java Development Kit     | Develop + Compile + Run Java programs | JRE + Compiler + Tools | ✅ Yes             | Developers |
| **JRE**   | Java Runtime Environment | Run Java programs                     | JVM + Libraries        | ❌ No (inside JDK) | End Users  |
| **JVM**   | Java Virtual Machine     | Executes bytecode                     | JIT + Memory mgmt      | ❌ No (inside JRE) | System     |
| **JIT**   | Just-In-Time Compiler    | Improves performance                  | Native code generator  | ❌ No (inside JVM) | JVM        |
Enter fullscreen mode Exit fullscreen mode

📦What is a Data Type?

A Data Type defines:

What kind of value can be stored

How much memory it uses

Examples of values:
Numeric values (10, 100)
Decimal values (10.5, 20.75)
Special characters ('A', '@')
True/False

Think of a data type as a container.

You must choose the correct container for the value you store.

🧩 Two Types of Data Types in Java
1️⃣ Primitive Data Types

These store simple values directly.

Data Type   Size    Example
byte           1 byte   50
short          2 bytes  1000
int        4 bytes  100000
long           8 bytes  100000000L
float          4 bytes  10.5f
double       8 bytes    10.5678
char           2 bytes  'A'
boolean      1 bit (logical)    true/false
Enter fullscreen mode Exit fullscreen mode

🧠 Understanding byte

1 byte = 8 bits
2^8 = 256 values

Range of byte:

-128 to 127

So this is valid:

byte tamilMark = 50;
byte englishMark = 50;
Enter fullscreen mode Exit fullscreen mode

But this is NOT valid:

byte value = 200; // ❌ Out of range
2️⃣ Non-Primitive Data Type

These store references (not direct values).

Example:

String name = "Kaveri";
Enter fullscreen mode Exit fullscreen mode

String can store multiple characters.

We will study String in detail separately (very important topic).

🧠 Primitive vs Non-Primitive (Major Difference)

** Primitive            Non-Primitive**
Stores actual value Stores reference (address)
Fixed size          Size depends on object
Stored in stack Stored in heap (reference in stack)
Example: int, byte  Example: String
Enter fullscreen mode Exit fullscreen mode

🧠 Memory Concept (Simple Understanding)

We learned about:

🔹** Stack Memory**

Stores primitive variables

Stores variable references

Example:

int tamil = 70;

Here:

int → data type

tamil → variable name

= → assignment operator

70 → value

; → end of statement

🏷 What is a Variable?

Variable = Name of the memory location.

Example:

byte tamil_mark = 70;
byte eng_mark = 60;
Enter fullscreen mode Exit fullscreen mode

Just like two students cannot have the same roll number,
Java does not allow duplicate variable names in the same scope.

🧠 Breaking Down This Line
byte tamil_mark = 70;

byte → data type
tamil_mark → variable name
= → assignment operator
70 → value
; → statement terminator

The semicolon tells Java:

The line of code is complete.

💻 Checking System RAM

We also learned how to check system memory:

Right-click This PC
Click Properties
View installed RAM

Memory matters because:

JVM uses system memory
Applications allocate memory during runtime

🎯** Day 3 Reflection**

Today I understood:

✔ What data types are
✔ Difference between primitive and non-primitive
✔ Memory basics (Stack concept)
✔ Why variable names must be unique
✔ How byte range is calculated

Strong fundamentals in Java will directly help in:

Selenium automation
Handling test data
Writing efficient scripts

Every day, I’m getting one step closer to my goal:

💎 Becoming a Master in Automation Testing using Selenium and Playwright.

🤖 A Small Note
I used ChatGPT to help structure and refine this blog while ensuring the concepts remain aligned with my trainer’s explanations.

Top comments (0)