Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
what is the advantage of using anonymous class in java?
the subclass will automatically overide the superclass method. doesn't it?
1 ответ
0
Probably for encapsulation mostly. Anything you can do with an anonymous class you could also do with a nested class or a normal class, but if it's a one time use thing there's no need to do that. And yes it will override superclass methods where applicable.
Check out some examples of the use of Google's Predicate class