Skip to content
Advertisement

Java Inner Classes

I’m new to Java and have the following question regarding inner classes:

When implementing an inner class, do I need to declare its attributes and methods scope i.e. public, private, protected?

EDIT: With the absence of delegates (as in C#) could someone mention how best to implement a messaging system in Java that enables communication between multiple forms (Jframe)?

I have read that I can use inner classes for this but I’m also told I should not implement inner classes more than a few lines in size. Which school should I follow?

Advertisement

Answer

If you want to.

An inner class is roughly speaking like any other class. (Except that if you don’t declare it static, it will have an EnclosingClass.this reference.)

10 People found this is helpful
Advertisement