Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>A pointer is a reference type</strong>; it refers to something. What you're basically asking is: "Does Java have Dobermans? Because some articles say it has dogs."</p> <p>As noted in <a href="http://en.wikipedia.org/wiki/Pointer_%28computer_programming%29" rel="nofollow">Wikipedia entry for Pointer</a>:</p> <blockquote> <p>A pointer is a simple, more concrete implementation of the more abstract reference data type. Several languages support some type of pointer, although some have more restrictions on their use than others</p> </blockquote> <p>It goes on to say this about <a href="http://en.wikipedia.org/wiki/Pointer_%28computer_programming%29#Java" rel="nofollow">Java specifically</a>:</p> <blockquote> <p>Unlike C, C++, or Pascal, there is no explicit representation of pointers in Java. Instead, more complex data structures like objects and arrays are implemented using references. The language does not provide any explicit pointer manipulation operators. It is still possible for code to attempt to dereference a null reference (null pointer), however, which results in a run-time exception being thrown. The space occupied by unreferenced memory objects is recovered automatically by garbage collection at run-time.</p> </blockquote> <p>Looking up <a href="http://en.wikipedia.org/wiki/Reference_%28computer_science%29" rel="nofollow">Reference</a> you find:</p> <blockquote> <p>In computer science, a reference is a value that enables a program to indirectly access a particular datum, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the datum, and accessing the datum is called dereferencing the reference. <BR><BR> A reference is distinct from the data itself. Typically, a reference is the physical address of where the data is stored in memory or in the storage device. For this reason, a reference is often called a pointer or address, and is said to point to the data. However a reference may also be the offset (difference) between the datum's address and some fixed "base" address, or an index into an array.</p> </blockquote> <p>Java chose to use the broader term "reference" instead of "pointer" because of the differences between Java and C. (Thus creating a sisyphus-like situation where we have to keep explaining that Java is pass-by-value). </p> <p>You don't have a C pointer, you have a Java Reference. This has nothing to do with a C++ reference, or pass-by-reference. </p> <p>Because Java is pass-by-value it is <em>similar</em> to using a C pointer in that when you pass it to a method, the value (e.g. memory address) is copied. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload