When I opened a java class, I got the following warning in the following line:
MyRec rec = new MyRec();
rec.getField(); <---- should use Class name when accessing static method
(or something to that effect).
It also puts a yellow marker next to that line.
After I did some other stuff (like compiling, creating a new class etc.),
that warning went away! Now I do not see anything. Any ideas? How can I get
all the warnings back?
Thanks,
Siva
Wald - 07 May 2004 20:26 GMT
> When I opened a java class, I got the following warning in the
> following line:
[quoted text clipped - 3 lines]
> method
> (or something to that effect).
That means getField() is declared as a static method in class MyRec. It's
more logical to call it by using the class name itself, rather than the
corresponding object's name.
So: use MyRec.getField() instead.
> It also puts a yellow marker next to that line.
>
> After I did some other stuff (like compiling, creating a new class
> etc.), that warning went away! Now I do not see anything. Any ideas?
> How can I get all the warnings back?
A big problem here is that you don't even mention which IDE you use.
Two possibilities:
- you removed the static identifier from the method getField()
- you tweaked some option in your IDE to ignore non-static access to static
members.
That's about everything I can say to help you, without more information.
Hope it helps,
Wald
Tony Morris - 08 May 2004 09:03 GMT
> After I did some other stuff (like compiling, creating a new class etc.),
> that warning went away! Now I do not see anything. Any ideas? How can I get
> all the warnings back?
http://www.xdweb.net/~dibblego/java/faq/answers.html#q34

Signature
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
Andy Fish - 13 May 2004 09:20 GMT
> When I opened a java class, I got the following warning in the following line:
>
[quoted text clipped - 7 lines]
> that warning went away! Now I do not see anything. Any ideas? How can I get
> all the warnings back?
sometimes I find with NetBeans the warning stays for a while after you have
fixed the problem. it just be that you had already fixed it but the view had
not refreshed itself
> Thanks,
> Siva