O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.9. Summary

In this chapter you have learned the essentials of how generic types are defined and used. In the next chapter you'll see how the java.util package provides you with an extensive range of standard generic types you can use in your programs. The important points you have seen in this chapter include:

  • A generic type, which is also referred to as a parameterized type, defines a family of classes or interfaces using one or more type parameters. Container classes are typically defined as generic types.

  • The argument you supply for a type parameter can be a class type or an interface type. It cannot be a primitive type.

  • You can limit the scope of type arguments for a given type parameter by specifying one or more bounds for the parameter using the extends keyword. The first bound can be a class or interface type; the second and subsequent bounds must be interface types.

  • You define a specific type from a generic type by supplying a type argument for each type parameter.

  • All types produced from a given generic type share the same run-time type.

  • A parameterized method defines a family of methods using one or more independent type parameters.

  • A parameterized method can be a member of an ordinary class type or a generic type.

  • You can use wildcards as type arguments in a parameterized type in situations where there is no dependency on a specific type.

  • You can constrain a wildcard type argument with either an upper bound that you specify using the extends keyword or with a lower bound ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required