In modern versions of Java, calling the instance method of sort() on the specific collection item you wish to sort may be more optimized. Collections.sort() will always work correctly but may not work as efficiently in some cases.
In the anonymous class, the compare method returns a value of type int but you return a value of type String(getname()), why isn't that an error?, where does the method compareTo come from it's not implemented anywhere in the classes
Creation of Anonymous Inner Classes was the main way of passing functionality into some other method before Java 8 brought lambdas. There are many tutorials and videos on "Anonymous Inner Classes" as well as using Lambdas to do the same thing more concisely and neatly. He shows what it looks like briefly ~11:30, but there are good places to see both the classical way of using an Anonymous Inner Class and the newer ways of using a lambda in the case of a one off. There are also more sophisticated ways of doing this using method references and comparing in the more modern Java versions.
the easiest way to make the Job done, thanks dude !
Nice video you really made me understand how this interface works
Really helpful!
Thanks!
Thank u bro u saved my life
Than you mr java made easy
Thansk a lot, but I don;t know when to use Comparator and when to use Comparable
In modern versions of Java, calling the instance method of sort() on the specific collection item you wish to sort may be more optimized. Collections.sort() will always work correctly but may not work as efficiently in some cases.
Can you post the code here please?
Nice explanation . Keep the work up
ty very much
In the anonymous class, the compare method returns a value of type int but you return a value of type String(getname()), why isn't that an error?, where does the method compareTo come from it's not implemented anywhere in the classes
Nice explanation
Presentation was also good
If Comparator is a interface then how can you create anonymous object/Instance out of it ?
Creation of Anonymous Inner Classes was the main way of passing functionality into some other method before Java 8 brought lambdas. There are many tutorials and videos on "Anonymous Inner Classes" as well as using Lambdas to do the same thing more concisely and neatly. He shows what it looks like briefly ~11:30, but there are good places to see both the classical way of using an Anonymous Inner Class and the newer ways of using a lambda in the case of a one off. There are also more sophisticated ways of doing this using method references and comparing in the more modern Java versions.
Very helpful
yeah right bhavya
could you made more videos like this please?
great video, keep it up!
Thanks a lot Bushari.
nice videos..