I have a method where I pass a variable (in this case an integer but could just as easily be a String) and want to use the variable as the object name when initialising. For example:
public static void printPlayerSetup(int playerPosition, String name) {
Player playerPosition = new HumanPlayer(name);
}
So for example, if playerPosition was "1" the new object created would be "1". Player is an abstract class and HumanPlayer is an extends this just to be clear.