TodayTools

Java flashcards

The steady language behind banks, Android roots and big business servers.

Donate
Beginner friendly, starts from zero
Section
How to study
0
JavaStart from zero · 1 of 11

What is Java, in one plain sentence?

Java is a programming language for writing programs that run the same way on Windows, Mac, Linux and servers, without rewriting them for each one.

Write once, run anywhere.
Show again
11 left
Got it

Tap to turn over. Swipe right if you know it, left to see it again.

All topics

What you will learn

  1. Start from zero

    • What Java is and why it exists4 cards
    • Key words4 cards
    • Getting ready3 cards
  2. Core basics

    • Running Java2 cards
    • Values and variables3 cards
    • Text3 cards
    • Control flow2 cards
    • Classes and objects3 cards
    • Collections2 cards
    • Errors2 cards
  3. Next steps

    • Object-oriented design3 cards
    • Pattern matching2 cards
    • Generics2 cards
    • Lambdas and streams3 cards
    • Exceptions and resources2 cards
    • Files, dates and the standard library2 cards
    • Build tools and testing2 cards
    • Concurrency basics2 cards
  4. Go deeper

    • The JVM inside4 cards
    • Memory model and concurrency5 cards
    • Performance and tooling3 cards
    • Modules and modern language2 cards
    • Security and production3 cards

Final test and certificate

10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.

Take the final test

Java at a glance

Java is a programming language that runs the same program on almost any computer, used for large, long-lived business software.

Like a shipping container: pack your goods once, and every port, truck and ship in the world knows how to carry it.

Words you will meet

Compiler
The tool (javac) that checks your code and turns it into bytecode
Bytecode
The in-between form of your program that any JVM can run
JVM
The Java Virtual Machine: the program that runs bytecode on your computer
JDK
The Java Development Kit: the download with the compiler, the JVM and tools
Class
A blueprint that describes a kind of thing, like an order or a customer
Object
One real thing made from a class, like order number 1042
Method
A named set of steps that belongs to a class
Type
The kind of value a variable holds, like a whole number or text

The steps

  1. 1. Start from zero (11 cards): What Java is, where it runs and the words you need.
  2. 2. Core basics (17 cards): Run programs, variables, text, control flow, classes, collections and errors.
  3. 3. Next steps (18 cards): Interfaces, pattern matching, generics, streams, files, builds, tests and virtual threads.
  4. 4. Go deeper (17 cards): JVM internals, garbage collection, the memory model, performance, modules and security.
All 11 cards in Start from zero
What is Java, in one plain sentence?
Java is a programming language for writing programs that run the same way on Windows, Mac, Linux and servers, without rewriting them for each one.
Why was Java made, and what problem did it fix?
In the 1990s a program built for one kind of computer would not run on another. Java added a middle layer, the JVM, so one program could run everywhere a JVM exists.
Where do you already meet Java in daily life?
Bank and payment servers, airline and train booking systems, large online shops, government portals, Android's foundations and Minecraft Java Edition all run on Java.
What everyday thing is the JVM most like?
A universal power adapter. Your program is the plug, each computer is a different wall socket, and the JVM sits in between so the plug fits every socket.
What happens between typing Java code and seeing it run?
You write a .java file. The compiler checks it and makes bytecode. Then the JVM reads that bytecode and runs it on your computer.
What are a class and an object, using a cookie cutter?
A class is the cookie cutter: the shape and rules. An object is one real cookie made with it. One Order class can make thousands of order objects.
What is a method, in plain words?
A named set of steps that belongs to a class, like calculateTotal on an order. You call it by name whenever you need those steps done.
Why does Java ask what type each value is?
So mistakes are caught early. If a box is marked to hold a whole number, Java refuses to put text in it, and tells you before the program ever runs.
What do you need before you start, and what does it cost?
A computer, a free JDK download (for example from the OpenJDK project), and a text editor or a free code editor. Java itself costs nothing to learn or use.
What does your very first Java program look like now?
Since Java 25 a tiny program can be just a main method in a file. IO.println prints a line of text on the screen.
After this topic, what will you be able to do?
Read and write real Java code, build small tools and services, understand job interview questions on Java, and move on to frameworks like Spring or to Android with Kotlin.
Java cheatsheet

Run and build

  • java Main.java Compile and run one file
  • javac -d out $(find src -name '*.java') Compile a source tree
  • java -cp out app.Main Run a class from compiled output
  • jar --create --file app.jar --main-class app.Main -C out . Package a runnable JAR
  • ./mvnw verify Maven: compile, test, package, checks
  • ./gradlew build Gradle: compile, test, assemble
  • jshell Try Java lines interactively

Everyday syntax

  • var total = 0L; Type inferred, still fixed
  • record Point(int x, int y) {} Immutable data class
  • switch (x) { case A -> ...; default -> ...; } Arrow switch, no fall through
  • if (o instanceof Order ord) {} Type test and bind
  • """ ... """ Multi-line text block
  • "%s: %.2f".formatted(name, amt) Format text with values
  • for (var item : items) {} Loop over every item

Collections and streams

  • List.of(a, b) / Map.of(k, v) Unmodifiable collections
  • new ArrayList<>(list) Mutable copy
  • map.getOrDefault(k, 0) Lookup with fallback
  • map.merge(k, 1, Integer::sum) Count occurrences
  • list.stream().filter(p).map(f).toList() Filter, transform, collect
  • Collectors.groupingBy(Order::city) Group into a map of lists
  • list.getFirst() / list.reversed() Sequenced collection helpers (21+)

Errors and resources

  • try (var r = ...) { } Auto-close resources
  • catch (IOException | SQLException e) Catch several types
  • Objects.requireNonNull(x, "x") Fail fast on null
  • Optional.ofNullable(v).orElse(d) Handle a maybe-missing value
  • throw new IllegalStateException(msg) Signal a broken state

JVM and diagnostics

  • -Xms1g -Xmx1g Start and max heap size
  • -XX:+UseZGC Low-pause garbage collector
  • -Xlog:gc* Log garbage collection
  • jcmd <pid> Thread.print Thread dump
  • jcmd <pid> JFR.start duration=60s filename=a.jfr Record a profile
  • -XX:+HeapDumpOnOutOfMemoryError Dump heap when memory runs out
Donate