Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLawrence Babay
6,941 Pointsprivate Game game;
How come in Prompter.java, instead of private String game is use, private Game game was used? Why?
Thanks!
5 Answers
Timothy Hilley
2,292 Pointsgame is not a string, it is an object. Prompter is not taking strings, it is taking instanciated objects.
Michael Clark
16,324 PointsHi Passavudh
A new game object has already been instantiated in hangman.java. In hangman.java that game object is being passed into the promoter constructor. The private Game game in prompter is just a private member variable that the passed in game object gets assigned to to be used by the promoter methods
Fahad Mutair
10,359 Pointshi Lawrence Babay ,
private Game game it will make object from Game.java class
private String game it will make String variable
Passavudh Sabpisal
4,474 Pointswhy don't we use (Game game = new Game()) for instatiating the object, I'm kind of confused pls help. What is the different between Game game = new Game() and private Game game
Lawrence Babay
6,941 PointsThank you all!
Passavudh Sabpisal
4,474 Pointswhy don't we use (Game game = new Game()) for instatiating the object, I'm kind of confused pls help. What is the different between Game game = new Game() and private Game game