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

private Game mGame

i know this is a variable, but how does the Game becomes a variable data type why do we call it instead of calling String, char etc?

1 Answer

Well, it does not exactly become a variable. It becomes an istance of a class, or an object.

In other words this is how you create a new object which you can then later use - call methods and access it's own variables.

ok, it finally makes sense now. Thanks!

Hemen Nabi
Hemen Nabi
15,192 Points

In other word, this would be object composition in Java, i.e. the use of instance variables that refer to other objects?