← All Exercises
Generic Methods with Bounds
intermediatejava
Background
Generic methods with bounds enable type-safe reusable algorithms in Java.
Problem
Create a generic method that finds the maximum element in a list using Comparable bounds.
Input
A list of Comparable elements
Output
The maximum element
Sample tests
Sample 1
Input: max(List.of(1, 3, 2))
Expected: 3
Your solution
Learning objective
Learn Java generics and bounded type parameters