CJCoding With Joseph
15free / daySign inCreate account

A type parameter can carry a bound. <T extends Comparable<T>> says that T may be any type whose values can be compared with each other, such as Integer, String or Double. That bound is what lets the method call compareTo on its parameters. The header is written. Complete the body.

Requirements: 1. larger(T a, T b) returns whichever of the two values is larger. 2. Decide with a.compareTo(b). It gives a positive number when a is larger, a negative number when a is smaller, and 0 when the two are equal. 3. When the two values are equal, return a.

Do NOT write a main method.

Expected output

8
pear
2.5

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
GenericsMethods
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.