Skip to content
Learn Netverks

Lesson

Step 22/36 61% through track

generics-intro

Generics introduction

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
intermediate

This lesson

An orientation to the Java track—how the server playground works, core vocabulary, and what you will practice next.

You need a clear map of the Java track so the JVM, compile step, and OOP vocabulary do not feel like magic.

You will apply Generics introduction in contexts like: Spring Boot APIs, banking systems, Android (with Kotlin), and batch/data pipelines on the JVM.

Write Java with a public class (lessons use Main), click Run on server—the dev runner runs javac then java; fix compile errors from stderr (LEARNING_RUNNER_ENABLED=true). Also read the interview prep blocks.

After HTML fundamentals and basic programming concepts—before or alongside SQL.

Generics parameterize types: ArrayList<String> holds only strings at compile time. They eliminate casts and catch type errors before runtime—similar to TypeScript generics but enforced by the JVM via erasure.

Class and method generics

class Box<T> {
    private T value;
    void set(T value) { this.value = value; }
    T get() { return value; }
}

Type erasure

Generic type parameters are erased at runtime—List<String> becomes raw List in bytecode. Do not rely on instanceof List<String>.

Important interview questions and answers

  1. Q: Why generics?
    A: Type safety and clearer APIs without casting.
  2. Q: What is erasure?
    A: Compile-time feature; runtime sees raw types for backward compatibility.

Self-check

  1. What symbol declares a type parameter?
  2. Why avoid raw ArrayList without type args?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Raw type danger?
  • List<String> benefit?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump