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 Data Structures Exploring the Java Collection Framework Maps

Sina Maleki
Sina Maleki
6,135 Points

Object reference

Hi guys I'm confused about "object references" in this course. I hope you'll help me. Best

What exactly are you confused about?

4 Answers

JT Keller
JT Keller
12,731 Points

alt text

  • An Object is an instance of a Class, it is stored somewhere in memory
  • A reference is what is used to describe the pointer to the memory location where the Object resides.
  • A variable is a means by which you can access that memory location within your application (its value is "variable"). While a variable can only point to a single memory address (if its not null), it may change and point to different locations through out the life cycle of the application
Sina Maleki
Sina Maleki
6,135 Points

I wanna know some definition about it

Paul Yorde
Paul Yorde
10,497 Points

Hey Sina, so an object reference gives us a way to access properties and methods associated with a specific object. Often, it will be stated as just passing an object. It means the same thing, it's just that technically speaking we don't work with objects, but instead we work with a reference to the object, which is to say an object reference. If you understand what it means to pass an object, then you understand what it means to pass a reference to object; at least for the sake of understanding what's going on.

Note however, understanding a reference is fundamental to object oriented programming.

Hope that helps. Best ~