It's not a secret anymore!
The moose likes Beginning Java and the fly likes About the Object reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About the Object reference" Watch "About the Object reference" New topic

About the Object reference

Ramesh Fernando

Joined: Nov 15, 2012
Posts: 2
Hi guys,
I'm pretty new to java.I'm confused about the the meaning of the "Object reference".
I mean why a reference is need? Can some one please help me how the references are stored??

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15002

Welcome to the Ranch!

Variables* in Java are references - a variable is not the object itself, it's a "pointer", or reference, that tells Java where in memory the object is located.

Have a look at the Cup Size Campfire Story, which explains this in more detail.

* (of non-primitive types)

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ramesh Fernando

Joined: Nov 15, 2012
Posts: 2
Thank you very much Jesper,for the warmth welcome to the Ranch.
I solved my doubt with the help of the article you have prescribed.
I hope to be with you guys and will try my best to be a good Programmer.I like Java!!
I agree. Here's the link:
subject: About the Object reference
It's not a secret anymore!