Yes. Create a java file called Global, or something like that, then include it in every class that needs it. From there you can access and manipulate them directly. |
|
So I'm making a program for the lulz, and I've realized something. Almost all of my classes need to access the same coordinates, x and y, and half of them need to alter x and y. So, I have the coordinates as public ints. But it's going to be a pain to have to type locationList[4][5].x every time I want to alter or use x. |
|
Abraxas
Originally Posted by OldSparta
Yes. Create a java file called Global, or something like that, then include it in every class that needs it. From there you can access and manipulate them directly. |
|
It's been a while since I've used Java as well, but if I understand your question correctly, you can simply declare x and y as global variables. This is accomplished by declaring them outside of all of your methods. |
|
You could have a superclass with those variables that all your classes extend. |
|
"Reality is merely an illusion, albeit a very persistent one." -Einstein
Abraxas
Originally Posted by OldSparta
Bookmarks