JQplus is contradicting Mughal! Its states the following as being a correct option: "Anonymous classes cannot be static" Mughal P243 states "The context determines whether the anomymous class is static" - meaning it can be static if defined in a static context (ie static method). Any opinions? My money is with Mughal... regards, George
According to the JLS an anonymous class is never static.
JLS �15.9.5 An anonymous class is always an inner class (�8.1.2); it is never static (�8.1.1, �8.5.2).
They can be declared in a static context however that does not make them static classes. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform [This message has been edited by Jane Griscti (edited July 02, 2001).]
Khalid Mughal posted the following on July 09, 2001 in the Programmers Certification Study forum in response to a similar question. JLS quote: "An anonymous class is never abstract (�126.96.36.199). An anonymous class is always an inner class (�8.1.2); it is never static (�8.1.1, �8.5.2). An anonymous class is always implicitly final (�188.8.131.52)." If you look carefully you will see that the word "static" refers to the keyword in the above quote. I choose to interpret this as meaning that an anonymous class cannot be declared static (<--- keyword). In our explanation, we are using the word "static" in the non-keyword sense of the word to indicate "an anonymous class declaration in a static context". As the examples presented in this discussion have shown, an anonymous class declared in a static context cannot access instance members in its enclosing context. This is the point we wanted to get across and the fact that such a class is instantiated without any outer object. We will make sure that such confusion about terminology does not arise in any future edition of the book. wbw, khalid mughal
No more fooling around. Read this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java