Hi Friends
Why are there no global variables in Java?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 20, 2012, 6:04 AM
However, you can effectively create global variables using public static fields. For example:
public class Global
{
public static int SomeVariable = 0;
}
You can then access the 'global' variable with the syntax Global.SomeVariable.