0Pricing
Java Academy · Lesson

Generics Basics (T, inference)

Learn generic type parameters T , why they give compile-time safety, and how the diamond operator infers types.

Why generics?

Generics add types to containers and utilities so the compiler can protect you. Benefits:

  • Type safety — no accidental mix of types.
  • No casts — cleaner code.
  • Reusable — one class works for many types.

What is T?

T (type parameter) is a placeholder for a real type. When you write Box<String>, the compiler treats T as String inside that usage.

All lessons in this course

  1. Interfaces in Practice
  2. Generics Basics (T, inference)
  3. Generic Methods/Classes
← Back to Java Academy