Can’t find a satisfactory answer anywhere.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All top-level classes are, by definition, static.
What the
staticboils down to is that an instance of the class can stand on its own. Or, the other way around: a non-static inner class (= instance inner class) cannot exist without an instance of the outer class. Since a top-level class does not have an outer class, it can’t be anything butstatic.Because all top-level classes are static, having the
statickeyword in a top-level class definition is pointless.Some code to play around with:
I put the “but don’t do this” in there because it’s really ugly code design. Instance inner classes should not be visible outside the outer class. They should only be used from within the outer class.