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?
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.