Why I am getting error in this code | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
1st May 2020, 4:50 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
3 Antworten
+ 3
Here you're calling the static method reverseOrder of the Collections class and it returns a Comparator. You're not calling a constructor. So there is no need to instantiate a new comparator as it is handled by the method. https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#reverseOrder()
3rd May 2020, 6:32 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Why we don't use new keyword at comparator
3rd May 2020, 6:18 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
Remove the 'new' keyword from the Comparator line 9.
1st May 2020, 5:06 AM
ChaoticDawg
ChaoticDawg - avatar