Encyclopedia > Reference (computer science)

  Article Content

Reference (computer science)

A pointer, or a reference, in Computer Science, contains the address of something in memory during the execution of a computer program. That something is a piece of the data of a program. It may be an integer or a string of characters, or some other thing, even an Object.

The difference between a reference and a pointer in Computer Science seems to be the ability to manipulate the memory address that the pointer points to. In Java, the misleading statement that "pointers do not exist in Java" is often confusing. It would be clearer to C programmers if that statement were changed to "Pointer arithmetic does not exist in Java."

It is possible in Assembly Code to move a pointer by one byte even though the thing it is pointing to is actually 4 bytes long. This is direct manipulation of the address the pointer contains. With pointer arithmetic in C, it is possible to "move a pointer" by the size of the thing it points to. For example, if it points to an integer and integers are stored in 4 bytes of memory space, then one could advance a pointer by 4 bytes via pointer arithmetic. This changes the address contained in the pointer. In Java, neither of these is directly possible. See iterators in Java for more information.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Bugatti

... from General Motors in 1993. A luxury saloon (EB112) was planned, but never got beyond the prototype stage. The company went bankrupt in 1995. In 1998 the Bugatti name ...

 
 
 
This page was created in 24.2 ms