Why can we have static final members but cant have static method in an non static inner class ?
Can we access static final member variables of inner class outside the outer class without instantiating inner class ?
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.
YOU CAN have static method in a static “inner” class.
To be precise, however,
Inneris called a nested class according to JLS terminology (8.1.3):Also, it’s NOT exactly true that an inner class can have
static finalmembers; to be more precise, they also have to be compile-time constants. The following example illustrates the difference:The reason why compile-time constants are allowed in this context is obvious: they are inlined at compile time.