(java@oneshot)logo/  logo/  logo/  logo/


Java Tutorial » Generics » Generics Basics  
12.1.5.Introducing Generic TypesPrevious/Next
  1. A generic type can accept parameters.
  2. A generic type is often called a parameterized type.
  3. You pass reference types in angle brackets to generic types.
List<E> myList;

E is called a type variable, namely a variable that will be replaced by a type.

  1. A generic type that uses a type variable E allows you to pass E when declaring or instantiating the generic type.
  2. If E is a class, you may also pass a subclass of E
  3. If E is an interface, you may also pass a class that implements E.
  4. By convention, you use a single uppercase letter for type variable names.
12.1.Generics Basics
12.1.1. Life without Generics
12.1.2. What Are Generics? A Simple Generics Example
12.1.3. Generics Work Only with Objects
12.1.4. A Generic Class with Two Type Parameters
12.1.5. Introducing Generic Types
12.1.6. Working with generic List
12.1.7. Nested generic type
12.1.8. A generic type can accept more than one type variables.
12.1.9. Raw Types and Legacy Code