¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
what is the advantage of using anonymous class in java?
the subclass will automatically overide the superclass method. doesn't it?
1 Respuesta
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