Title: Key Concept - Generic types
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

Generic types may be applied to a class or interface.

Generic types are usually signified by single uppercase letters, are listed after the class/interface name within angle brackets, and are referred to in the body of the class/interface.

- The specific types are passed into the class/interface when it is referenced.  This is similar to passing arguments into a method.
- The specific types may be non-primitive type including classes, interfaces, arrays, and strings.

class declaration with generic types syntax:

class <class-name> <T1, T2, …, Tn>
{
<block containing references to T1, T2, …, Tn>
}

Where T1, T2, …, Tn are the generic types.

If a specific type is not passed into the class/interface when it is referenced, then the result is a raw type.

Raw types are used in legacy code because many API classes, like Collections, were not generic prior to JDK, version 5.

For additional study, view resources under:

- Level 2 Study Materials: Unit 2
- Level 2 Study Materials: Unit 10