Advanced Features in Java: Wildcards and Type Capture

Java    |    Expert
  • 12 videos | 1h 29m 20s
  • Includes Assessment
  • Earns a Badge
Rating 5.0 of 2 users Rating 5.0 of 2 users (2)
In this course, you'll explore how wildcards and type capture work, as well as how type erasure manifests itself in compiled bytecode. You'll start by examining how the wildcard operator, represented in syntax by the ? character, can be used in situations where you don't know up-front what type argument to specify for a particular type parameter. Next, you'll learn the three types of wildcard type parameters. Unbounded wildcards, where you know nothing at all about the type; upper bounded wildcards, which define type parameters that must inherit from a specific base class or interface; and finally lower bounded wildcards, which can be used to specify constraints in the other direction - namely that the type must be a super-class of a specified type. Next, you'll see that capture errors occur when Java is unable to infer the correct type to pencil in as the type argument for a given type parameter. Finally, you'll examine bytecode to see that whenever you create a class or method with a type parameter, Java creates just one single copy of such code, and pencils in a type parameter of java.lang.Object. It also adds various type checks to ensure that the code is used correctly. This is known as type erasure and forms the basis of the great performance of Java generics.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Recognize how you can constrain type parameters to extend the comparable and serializable interfaces
    Demonstrate various relationships between base and derived classes in the presence of type parameters
    Recognize how type parameters may exist only in the base class, or only in the derived class, or in both
    Recognize use-cases where a base class specifies one type parameter and the derived class specifies multiple type parameters
    Describe how wildcards mitigate some limitations of invoking methods with generic input arguments
  • Use upper bounded wildcards to specify that a type parameter must be a sub-class of a certain type
    Recognize how unbounded wildcards can be used where no information about inheritance relationships is available
    Use lower bounded wildcards to specify that a type parameter must be a super-class of a certain type
    Recognize scenarios where capture errors might occur and some potential fixes for such capture errors
    Analyze compiled bytecode to see how java uses type erasure to ensure type safety and prevent code bloat
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 54s
  • 11m 49s
    Upon completion of this video, you will be able to recognize how you can constrain type parameters to extend the Comparable and Serializable interfaces. FREE ACCESS
  • Locked
    3.  Introduction to Inherited Type Parameters
    10m 1s
    Learn how to apply various relationships between base and derived classes in the presence of type parameters. FREE ACCESS
  • Locked
    4.  Type Parameters in an Inheritance Hierarchy
    9m 56s
    Upon completion of this video, you will be able to recognize how type parameters may exist only in the base class, or only in the derived class, or in both. FREE ACCESS
  • Locked
    5.  Experimentation with Type Parameters in Inheritance
    8m 15s
    Upon completion of this video, you will be able to recognize use-cases where a base class specifies one type parameter and the derived class specifies multiple type parameters. FREE ACCESS
  • Locked
    6.  Introduction to Wildcards
    8m 21s
    Upon completion of this video, you will be able to describe how wildcards mitigate some limitations of invoking methods with generic input arguments. FREE ACCESS
  • Locked
    7.  Upper Bounded Wildcards vs. Bounded Type Parameters
    5m 13s
    Find out how to use upper bounded wildcards to specify that a type parameter must be a subclass of a certain type. FREE ACCESS
  • Locked
    8.  Unbounded Wildcards
    6m 3s
    Upon completion of this video, you will be able to recognize how unbounded wildcards can be used where no information about inheritance relationships is available. FREE ACCESS
  • Locked
    9.  Lower Bounded Wildcards
    7m 55s
    Find out how to use lower bounded wildcards to specify that a type parameter must be a superclass of a certain type. FREE ACCESS
  • Locked
    10.  The Capture Error
    6m 54s
    After completing this video, you will be able to recognize scenarios where capture errors might occur and some potential fixes for such capture errors. FREE ACCESS
  • Locked
    11.  Type Erasure
    9m 13s
    In this video, you will analyze compiled bytecode to see how Java uses type erasure to ensure type safety and prevent code bloat. FREE ACCESS
  • Locked
    12.  Course Summary
    2m 46s

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

YOU MIGHT ALSO LIKE

Rating 4.5 of 84 users Rating 4.5 of 84 users (84)
Rating 4.4 of 56 users Rating 4.4 of 56 users (56)
Rating 4.5 of 36 users Rating 4.5 of 36 users (36)

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 5.0 of 4 users Rating 5.0 of 4 users (4)
Rating 4.4 of 50 users Rating 4.4 of 50 users (50)
Rating 4.5 of 100 users Rating 4.5 of 100 users (100)