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 Meet Objects Creating Classes

David McNamara
David McNamara
382 Points

What if Example.java only contains "class PezDispenser{}"?

I set Example.java to "class PezDispenser{}"? Dispenser became: PezDispenser@6d06d69c. What's it mean? What'd Java do?

1 Answer

I don't clearly understand your question, but I am going to assume that you created an instance of class ... aka, you instantiated an object from a class as in:

Myclass obj = new Myclass();

so now obj is an object instance of Myclass.

stated differently, if MyClass is a blueprint for a house, obj is a house you built from this blue-print.

Myclass obj2 = new Myclass();

again, if MyClass is a blueprint for a house, obj2 is yet another house you built from this same blue-print.

obj and obj2 (house 1 and House 2) may look similar, but most likely, they have different exterior color, my one with shingles and the other with metal roofs .... so they have have different attributes that give each house (each obj) it distinctive characteristic.

Now

first house (obj) address is 1234 My-street, My-town, My-country, My-zipCode

second house (obj2) address is 5678 Your-street, Your-town, Your-country, Your-zipCode

obj@6d06d69c. live at some memory location represented by this hex address directly or indirectly ... the details are not important

obj@6906dc9c. live at some memory location represented by this hex address directly or indirectly ... the details are not important

long way to explain the concept

it this answers your question, please mark the question as answered.