Quote Originally Posted by pstudio View Post
You often only need the comparator in one place and you only need to implement the method 'compare'. In these cases it can be nice to simply use an anonymous class written as an expression when you need it, in stead of going through the trouble of defining a new class and implement it. Anonymous classes also have the extra benifit that they have access to members in the scope they are defined in.
Why would you create a new class which incorporates only one method and such method is only used on one place? Wouldn't it be easier to just write your method nested within some other method where it is needed?
Based on my understanding the purpose of classes is the ability to join a group of methods which serves similar purpose into one object so that you can easily reuse this object on different places without the need to redeclare all of those methods.