instance method writes to a static field. This is tricky to get correct

hi,

i am assinig a static refence to an obect, and acess this refrence outside the class.

public static loadingDialog StatusWndw = null;

StatusWndw = new loadingDialog(this);

i want toacess StatusWndw this out side the class but find bug show me generally bad practice.

pls reply.

regards,

lkkj

[350 byte] By [lkkja] at [2007-11-27 11:03:49]
# 1

There are lot of false positives with find bugs so it is up to you to decide whether you want to keep the code.

If there is a good reason to keep the variable StatusWndw as static leave it as it is. In fact most singleton classes need to have static variable that is initialized at some point.

However you might want to make the StatusWndw as private and provide a gettor for it?

AshwineeJhaa at 2007-7-29 12:53:17 > top of Java-index,Java Essentials,New To Java...
# 2

Double post

http://forum.java.sun.com/thread.jspa?threadID=5196620&messageID=9776475

Please don't do that

dwga at 2007-7-29 12:53:17 > top of Java-index,Java Essentials,New To Java...
# 3

And please, read JavaCodeConvention

the right way should be

public static LoadingDialog statusWndw = null;

statusWndw = new LoadingDialog(this);

cya

pbulgarellia at 2007-7-29 12:53:17 > top of Java-index,Java Essentials,New To Java...