0

what is the advantage of using anonymous class in java?

the subclass will automatically overide the superclass method. doesn't it?

16th Jan 2018, 9:33 PM
aliakbar sultani
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
17th Jan 2018, 7:50 AM
Dan Walker
Dan Walker - avatar