irishScott
Lifer
Is there a way to tell if a variable is static or not without reading the src?
Originally posted by: Thyme
See if this.<variable> resolves to it (instance) or if <classname>.<variable> resolves to it (static) or if neither (local)
That ought to tell you.
My IDE (eclipse) tells me where a variable is defined.
Why do you need this?
The class name shall always be used when referring to class (static) variables or methods. Object names shall not be used even though the Java language allows them. Unqualified references to class (static) variables shall not be used. Examples:
SomeClass.mStaticVariable; // good
SomeClass.staticMethod(); // good
SomeClass myObj;
myObj.mStaticVariable; // bad
myObj.staticMethod(); // bad