A complete beginner-friendly guide to understanding what Java is, how it works, and why it matters.
Java is a high-level, object-oriented, class-based programming language designed to have as few implementation dependencies as possible. It was created by James Gosling at Sun Microsystems and released in 1995. Today it is owned and maintained by Oracle Corporation.
The most important principle behind Java is "Write Once, Run Anywhere" (WORA). This means Java code compiled on one platform can run on any other platform that has a Java Virtual Machine (JVM) installed — without recompiling.
💡 Quick fact: As of 2024, Java consistently ranks among the top 3 most used programming languages worldwide (TIOBE Index).
| Year | Milestone |
|---|---|
| 1991 | Project "Oak" started by James Gosling at Sun Microsystems |
| 1995 | Renamed to Java; officially released to the public |
| 1996 | Java 1.0 released — first stable version |
| 2004 | Java 5 — Generics, Annotations, Autoboxing introduced |
| 2014 | Java 8 — Lambda Expressions and Stream API (biggest modern update) |
| 2017 | Java 9 — Module System (Project Jigsaw) |
| 2021 | Java 17 — LTS release with Records, Sealed Classes |
| 2023 | Java 21 — LTS release with Virtual Threads (Project Loom) |
Unlike C or C++ which compile directly to machine code, Java uses a two-step process:
javac) converts your .java source file
into bytecode — a platform-neutral
.class file.
YourProgram.java ? [javac compiler] ? YourProgram.class (bytecode)
YourProgram.class ? [JVM on any OS] ? Runs on Windows / Mac / Linux
This two-step design is why Java is platform-independent. The bytecode is the same everywhere; only the JVM differs per operating system.
Easy way to remember: You write source code,
javac translates it, and the JVM runs
the translated bytecode.
These three terms confuse most beginners. Here's a clear breakdown:
| Term | Full Form | What it does | Who needs it? |
|---|---|---|---|
| JVM | Java Virtual Machine | Executes bytecode. Abstract layer between Java program and OS. | Everyone (included in JRE) |
| JRE | Java Runtime Environment | JVM + core libraries needed to run Java programs. | End users who only run Java apps |
| JDK | Java Development Kit |
JRE + compiler (javac) +
debugger + dev tools.
|
Developers who write Java code |
📌 Simple rule: To write Java ? install JDK. To run a Java app ? JRE is enough.
A variable is a named location used to store a value while a program runs. Every Java variable has a data type, a name, and a current value. Java is statically typed, so the type is checked when the code is compiled.
int age = 25;
String name = "Asha";
boolean isLearning = true;
The general declaration format is:
dataType variableName = value;
In the example above, int,
String, and
boolean are data types.
age, name,
and isLearning are variable names.
int score; // declaration
score = 95; // initialization
score = 100; // reassignment
System.out.println(score); // 100
A local variable must be assigned a value before it is read. Java does not automatically give local variables a default value.
| Kind | Declared where? | Lifetime |
|---|