I'm trying to return an object from an arraylist I have, which contains different opponents for my text-based fighting game. The opponents in the arraylist have different "deadlylevels", to seperate one easy opponent from a tough one.
To explain it differently; Let's say I have three opponents in my arraylist, and they have the deadlylevels of 30, 40 and 50, respectively. I want to return the most deadliest of them, so that would be the opponent who has a deadlylevel of 50.
I have already given them different deadlylevels, but I'm not sure how to return the opponent that has the highest deadlylevel.
Listwith aComparatorthat uses the "deadlylevel" as criterion and get the first (or last) element.