Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Prompting for Guesses

public Prompter (Game game). I'm lost..

I'm a bit lost here. So we're creating a constructor of

public Prompter (Game game) {


How does this work? I understand if it's public Prompter (String game), or public Prompter (Int game), but since the type is something that we created, how this actually works?

Thank you,

1 Answer

It actually works in the same way as if you had created a constructor of public Prompter(String string). String is actually a predefined class in the Java language. So what you'd be passing in to the constructor in that case is a String object (an instance of the String class). The only difference in the case of public Prompter(Game game) is that you would be passing in an Game object (an instance of the Game class).

And what's the point of doing this? Thanks in advance.