A
11
C
java.lang.Object@74c3aa
java.lang.Object@1d9fd51
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
C:\>javac Class0.java
Class0.java:18: inner classes cannot have static declarations
private static final Object aa;
^
1 error
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Gasan Gouseinov wrote:Ernest, I don't clearly understand what you mean by saying that compile time static members constants treated as a macros. But, you're right, in other words, only string or number literals can be static member constants for anonymous inner class (probably for all inner classes, but I don't know).
Gasan Gouseinov wrote:what I'm trying to say is that is legal to have static member in inner anonymous class only of primitive type or String type, but only of them. Why?!
Gasan Gouseinov wrote:I didn't found the best solution for this. Probably, it's to add methods for that fields, which will initialize them if they wasn't.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |