Malcolm McLean wrote:
>
<su***********@gmail.comwrote in message news:
>dear all,
can anyone explain the differences between pointer variable and
reference variables ?
References exist in Java and C++, and are basically syntactic sugar for
pointers. They point only to one object, and may never be null. However
the variable is passed as an address, ie a pointer.
<off-topic>
Dunno about C++, but what you say about Java is wrong on
all three points (or at least on two and a half points, allowing
some wiggle room in interpreting "they" in the second point):
1) A Java "reference" *is* what C calls a "pointer," not a
pointer hiding behind a sugar-coated facade. (Java gives
the programmer little freedom to manipulate its pointers,
but they're indisputably pointers. Note what's thrown for
misuse of a null reference: NullPointerException.)
2) A Java reference value refers to only one object, just as
a C pointer value refers to only one object. A Java
reference variable, just like a C pointer variable, can
refer to different objects at different times.
3) A Java reference value or variable can be null.
</off-topic>
--
Eric Sosman
es*****@ieee-dot-org.invalid