CJCoding With Joseph
15free / daySign inCreate account

Write a generic static method that finds the largest item in an array of any comparable type. This time the method header is yours to write too, including the bounded type parameter.

Requirements: 1. Inside Finder, write a public static method named findMax. It declares one type parameter T that is bounded by Comparable<T>, takes one parameter of type T[] and returns a T. 2. It returns the largest item in the array. x.compareTo(y) is positive when x is larger than y. 3. The array always holds at least one item. Do not sort the array or change it in any way.

Do NOT write a main method.

Expected output

17
plum
2.5
[4, 17, 9]

= 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.