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)