Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Can an interface define inner classes?



It comes in handy if you want to provide an Enum in the definition of your interface. Though I don't know any real cases where this provides a clear benefit, since there's no special access to a class instance that you'd normally get with inner classes within classes.

You can also define fields (must be final, but can non static!). Anyone know why you would ever use this? And does the implementing class inherit them as expected?