Why Java?
Java compiles to bytecode, which runs on the JVM — the same .class file works on
Linux, macOS and Windows. A new release ships every six months, an LTS release every two years.
| Version | Year | Highlights |
|---|---|---|
| 8 | 2014 | lambdas, streams, Optional, java.time |
| 11 LTS | 2018 | HTTP client |
| 17 LTS | 2021 | records, sealed classes, text blocks, switch expressions |
| 21 LTS | 2023 | virtual threads, pattern matching for switch |
| 25 LTS | 2025 | compact source files & IO, module imports, scoped values |
Where it is used
Backends (Spring Boot, Quarkus), Android, big data (Kafka, Spark, Elasticsearch), and most developer tooling.
Java ≠ JavaScript
Unrelated languages. The name was a 1995 marketing decision.
Three acronyms
- JDK — compiler, JShell, tools (what you install)
- JRE — JVM + standard library
- JVM — runs bytecode, compiles hot code to machine code (JIT), collects garbage
You never free memory manually.
Static typing
Types are checked at compile time:
var infers the type — it does not make Java dynamic:
Conventions
| Element | Style | Example |
|---|---|---|
| classes, records, interfaces | UpperCamelCase | BankAccount |
| methods, variables | lowerCamelCase | computeTotal |
| constants | UPPER_SNAKE_CASE | MAX_SIZE |
| packages | all lowercase | com.example.shop |
| file name | = public class name | BankAccount.java |
Four spaces of indentation, opening brace on the same line.
Comments
What Java does not have
- free functions (every method belongs to a type)
- multiple class inheritance (interfaces instead)
- pointer arithmetic or manual memory management
- operator overloading (
+on strings is the one exception)
★ Exercises
- Which Java version is active on your machine? Is it an LTS?
- Rewrite in proper Java style: max retry count (constant), user profile (class), load data (method).
- Explain JDK vs JRE vs JVM in your own words.
- Why does
var x;not compile? Try it in JShell and read the error.