File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Reference variable in Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reference variable in Inner Class" Watch "Reference variable in Inner Class" New topic
Author

Reference variable in Inner Class

ronnir paterl
Greenhorn

Joined: Oct 18, 2007
Posts: 11
Hi,

I had a doubt about final static fields in Inner classes.

According to the JLS,
Inner classes may not declare static members, unless they are compile-time constant fields

So my question is that why isn't object reference type (o1) considered to be compile-time constant field when used with final and static instead of just final?

class TLC{
class Inner{
//final static Object o1 = null;

Object o2 = null;
final Object o3 = null;

final static int j = 22;
int s = 4;
}
}

The is the error for the commented line

"The field o1 cannot be declared static; static fields can only be declared in static or top level types"



Thanks
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 375
Check the uncommented static members...

So we may have to raise the question "what are compile time constants"?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reference variable in Inner Class