03-14-2010, 09:12 AM
(This post was last modified: 03-14-2010, 09:13 AM by Project Evolution.)
Try using that static field with a non-static method. ;) It wont work.
Another way is to first create a public field like so,
Make sure you keep public at the beginning or it doesnt work.
Then in the class you want to call it from, you create an object of the other class and call it like this,
This will work with any non-static methods. But the way one you posted only works with static methods. Understand?
Another way is to first create a public field like so,
Code:
public int globalInt = 0; // idk
Then in the class you want to call it from, you create an object of the other class and call it like this,
Code:
GlobalDataStore gDS; // invokes the GlobalDataStore class
public void someMethod() {
gDS.globalInt = 1; // calls the variable, and sets it to 1
}
This will work with any non-static methods. But the way one you posted only works with static methods. Understand?