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 trial

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.