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?
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?
Your list is empty. According to the docs the mentioned exception happens when the collection is empty