Exercises
20.3 (Explain Notation) Explain the use of the following notation in a Java program:
public class Array<T> { }
20.4 (Generic Method
selectionSort
) Write a generic methodselectionSort
based on the sort program of Fig.19.4 . Write a test program that inputs, sorts and outputs anInteger
array and aFloat
array. [Hint: Use<T
extends
Comparable<T>>
in the type-parameter section for methodselectionSort
, so that you can use methodcompareTo
to compare the objects of the type thatT
represents.]20.5 (Overloaded Generic Method
printArray
) Overload generic methodprintArray
of Fig.20.3 so that it takes two additional integer arguments,lowSubscript
andhighSubscript
. A call to this method prints only the designated portion of the array. ...
Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.