-1

I read about the indexOf and .max methods and tried to do this

int indexOfMax =list.indexOf(Collections.max(list));

But I get a NoSuchElementException. How else could one go about this?

1 Answers1

0

Your list is empty. According to the docs the mentioned exception happens when the collection is empty

kkica
  • 4,034
  • 1
  • 20
  • 40