Results 1 to 2 of 2
Thread: global variables
- 03-08-2009, 07:05 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 15
- Rep Power
- 0
global variables
I have a problem on how to define a global variable. Does anyone know how I can make from P1 a global variable so that other classes can use it too?
Java Code:public class X { public String P1; public String P2; public PlayerID(String player1,String player2) { P1 = player1; P2 = player2; } }
-
Consider creating a Player class that holds a String name field and have "X" accept two Player objects. How to make it visible to critical parts of the program will depend on how the Program structure. My guess is that you'll probably make it a class variable of some "Game" class, and then pass it as a parameter to any other objects used by Game.
Similar Threads
-
global declaration in java
By gpveena20 in forum New To JavaReplies: 13Last Post: 02-12-2009, 10:25 PM -
Would you like to publish your game global?
By tridens in forum Reviews / AdvertisingReplies: 0Last Post: 08-18-2008, 09:42 AM -
Global constants
By Java Tip in forum Java TipReplies: 0Last Post: 02-17-2008, 09:06 AM -
Declaring global variables
By eva in forum New To JavaReplies: 3Last Post: 12-23-2007, 12:11 AM -
save global data in servlets
By Marty in forum Java ServletReplies: 1Last Post: 05-31-2007, 06:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks