Global Variable in JAVA
843807Sep 8 2010 — edited Sep 8 2010Hi I am new to Java but have been programming in other languages for sometime.
What I want to achieve is to have some global variables that I can use in other classes. This was particularly difficult because I want to use these global variable in Switch/Case statements. I thought this was solved by creating the following class
public final class IntObj {
public static final int ftsefut_contract_id = 2;
}
so in another class i would use IntObj.ftsefut_contract_id in the switch/case and it worked. However, i now am begining to think this is not working. Usng NetBeans, if I change the value of ftsefut_contract_id from 2 to 3 and "clean and rebuild", I am still seeing the value of ftsefut_contract_id to be 2 and not the new value (ie 3) that I have inputed. Can someone please explain is there a better method of having global variables and if not how do I get NetBean or the project to flush itself and reload the new values each time I rebuild.
Thanks