exercises in using classes that are parameterized with generic types
in Pair
example
For each item in this section, find exemplifying code in the Pair
example.
For easy reference in the future, take advantage of GitHub's "Copy permalink" command: click on a line number, then click on the resulting ellipsis. Use the permalink as the URL in GitHub-Flavored Markdown.
- (an example of this task) the declaration of a
main
method:
public static void main(String[] args)
- definition that a class / type that is parameterized by a generic type,
T
:
your exemplifying line from the Pair example here
in UserOfPair
- declaration of a variable that can hold a reference to an instance of such a class:
your exemplifying line from the Pair example here
in Pair
- assignment to such a variable:
your exemplifying line from the Pair example here
in UserOfPair
- declaration of a method that returns an instance of such a type:
your exemplifying line from the Pair example here
in Pair
- successful instantiation of an instance of such a class:
your exemplifying line from the Pair example here
in UserOfPair
- unsuccessful instantiation of an instance of such a class, caught by the compiler:
your exemplifying line from the Pair example here
- a variable that can hold a reference to an instance of the generic type in a class / type that is parameterized by a generic type:
your exemplifying line from the Pair example here
in Pair
- the declaration of a method or constructor that accepts a parameter of a generic type:
your exemplifying line from the Pair example here
in Pair
- the declaration of a method that returns a value of a generic type:
your exemplifying line from the Pair example here
in Pair