• Post Reply Bookmark Topic Watch Topic
  • New Topic

dereferencing in java  RSS feed

 
sanjay kumar gupta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have serached on Google but could't find exact concept of derefencing in java,I have few doubt about this concept please clear --

1-is java support derefencing?
2- is Derefencing and aliase is same word?
3- is I am correct if
A a1= new A();
and then later i try to use properties or function of a1

is this called derefencing?
or

if
A a1=new A();
a1= null;
or assigning null to reference is called derefencing?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sanjay kumar gupta wrote:I have serached on Google but could't find exact concept of derefencing in java,I have few doubt about this concept please clear --

1-is java support derefencing?


Yes.


When we access a member of the object pointed to by member variable x using "x." we say that we are dereferencing the x variable (or dereferencing the reference that's stored in x).

2- is Derefencing and aliase is same word?


No.

3- is I am correct if
A a1= new A();
and then later i try to use properties or function of a1

is this called derefencing?


Yes.

or

if
A a1=new A();
a1= null;
or assigning null to reference is called derefencing?


No.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aliasing means using two variables to point to the same reference
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Aliasing means using two variables to point to the same reference


<quibble>
I disagree. Variables don't "point to" references. They hold references as their values. In C++, I've heard references referred to as an "alias" for the variable. There's nothing comparable in Java, and I've never heard the term "alias" used to describe that situation.

But perhaps I'm missing out on some (semi-?)standard part of the lexicon?
</quibble>
 
sanjay kumar gupta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All right, “point to” was wrong.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!