Java Syntax, Primitive Types & Main Method Entrypoint
Write your first Java application, understand JVM static compilation, bytecodes, primitive memory layouts, and method declarations.
Learning Objectives & Core Execution Model
### Learning Objectives
- Understand the complete Java execution lifecycle from source code (`.java`) to JVM bytecode (`.class`).
- Master Java's 8 primitive data types (`byte`, `short`, `int`, `long`, `float`, `double`, `char`, `boolean`).
- Understand variable declaration, strict static typing, and memory allocation in Java.
- Execute Java applications using the static `public static void main(String[] args)` entrypoint method.
---
### The Java Virtual Machine Execution Model
Java is a compiled, statically-typed language designed around the principle of *"Write Once, Run Anywhere"* (WORA). When you write Java source code in a file ending with `.java`, the Java Compiler (`javac`) parses the human-readable text and compiles it into platform-independent intermediate instructions known as **JVM Bytecode** saved in `.class` files.
The **Java Virtual Machine (JVM)** reads these bytecode files at runtime and uses Just-In-Time (JIT) compilation to convert bytecode into host hardware machine code instructions dynamically.
Key Terminology & Primitive Matrix
### Key Terminology
- **JDK (Java Development Kit)**: Complete software development suite containing `javac` compiler, debugger, tools, and runtime environment.
- **JRE (Java Runtime Environment)**: Libraries and components required strictly to execute compiled Java bytecode applications.
- **JVM (Java Virtual Machine)**: Abstract computing machine that executes compiled Java bytecode instructions.
- **Static Typing**: Type checking enforced at compile-time; variable types cannot change after declaration.
---
### Java 8 Primitive Data Types
| Type | Bits | Default Value | Value Range |
| :--- | :--- | :--- | :--- |
| `byte` | 8 | `0` | -128 to 127 |
| `short` | 16 | `0` | -32,768 to 32,767 |
| `int` | 32 | `0` | -2,147,483,648 to 2,147,483,647 |
| `long` | 64 | `0L` | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
| `float` | 32 | `0.0f` | ~6-7 decimal digits precision |
| `double` | 64 | `0.0d` | ~15-17 decimal digits precision |
| `boolean` | 1 | `false` | `true` or `false` |
| `char` | 16 | `'\u0000'` | Single 16-bit Unicode character |