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
242

... century Decades: 190s 200s 210s 220s 230s - 240s - 250s 260s 270s 280s 290s Years: 237 238 239 240 241 - 242 - 243 244 245 246 247 Events Patriarch Titus[?] ...

 
 
 
This page was created in 34.9 ms