Programming languages

Java

A statically typed JVM language: the base of enterprise backends, Android and large systems.

What it is

Sun Microsystems created Java, with a first release in 1995. Code compiles to bytecode and runs on the JVM, so it works on any platform with a Java Virtual Machine.

The language evolves through OpenJDK and the JEP process. New versions ship every six months, and LTS releases (17, 21, 25) are supported for a long time. Modern Java has records, sealed classes, pattern matching and virtual threads.

The ecosystem is huge: Spring Boot, Maven and Gradle, Hibernate. Kafka and Elasticsearch are written in Java. The JVM also runs Kotlin, Scala and Clojure.

Use it when

  • Enterprise backends and financial systems where maturity and stability matter.
  • Large teams and long projects: strict typing and tooling help maintenance.
  • High-throughput, long-running systems (the JIT warms up well).

Avoid it when

  • Small scripts and CLIs where fast startup and low memory matter.
  • Quick prototypes: the code is wordier than Python or Kotlin.

Key concepts

JVM
The virtual machine that runs bytecode, manages memory and optimizes hot code through the JIT.
Garbage collector
Automatic memory reclamation. Several collectors (G1, ZGC) trade off pause times and throughput.
Record
A compact immutable data type: constructor, accessors, equals and hashCode are generated.
Virtual threads
Lightweight threads (Java 21) for many blocking operations without complex async code.
Maven / Gradle
Build and dependency management tools.

Example

A record and the Stream API to filter a list.

Cheat sheet

Java cheat sheet
Command or codeWhat it does
javac Main.java && java MainCompile and run
java Main.javaRuns a single file without a separate compile step
List<String> xs = List.of("a", "b");Immutable list
Map<String, Integer> m = new HashMap<>();Key value map
list.stream().filter(x -> x > 0).toList()Filtering with a Stream
record Point(int x, int y) {}Immutable data type
var user = new User();Local variable type inference
try (var in = Files.newInputStream(p)) { }Automatic resource closing
Optional.ofNullable(x).orElse(d)Default value instead of null
mvn testRuns Maven tests

How to learn it

  1. Install JDK 21 or newer and run your first program from an IDE.
  2. Learn the syntax, classes, objects and packages.
  3. Study collections (List, Map, Set), generics and exception handling.
  4. Understand the Stream API, lambdas and Optional.
  5. Go deeper into OOP: interfaces, inheritance, records and sealed classes.
  6. Meet Maven or Gradle and build a console application.
  7. Write tests with JUnit 5.
  8. Move on to Spring Boot and build a REST API with a database.

Interview questions

  1. 1. How do JDK, JRE and JVM differ?

    The JVM runs bytecode. The JRE is the JVM plus the standard library to run programs. The JDK adds the compiler and developer tools. Today a standalone JRE is rarely shipped.

  2. 2. How does garbage collection work?

    It finds objects with no references and frees their memory. Memory is split into generations (young, old) because most objects die young. G1 is the default collector, ZGC gives very short pauses.

  3. 3. What is the difference between equals and ==?

    == compares references (same object), while equals compares content if the class overrides it. When you override equals you must override hashCode too.

  4. 4. What are virtual threads?

    Lightweight threads managed by the JVM, not the OS. You can create millions, so a thread-per-request style scales without reactive programming.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).