I recently encountered a code in my java program that is as follows..
Yeah, this is an anonymous inner class. ActionListener itself is an interface, but since it is being invoked and the entire method set is being declared as a part of the class body, this is valid code. Prior to Java 8, it's also the closest thing we have to a closure in Java.
So effectively you create an unnamed instance and provide that as the argument. That particular instance can never be used again.
|All times are GMT +1. The time now is 07:35 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.