pointer : Java Glossary


Strictly speaking, in Java, a pointer is a reference that is guaranteed not to be null. However, when people use the term pointer, they usually mean C++ style direct hardware address pointers, with pointer arithmetic.

You may have heard some FUDster claiming that Java sucks roadkill because it has no pointers. He jeers, How can you write serious code without pointers? In Java are you actually limited to FØRTRAN style problems: no linked lists, no queues etc? Java does not have raw pointers like C or C++. It has something almost as powerful, but many times safer called references (Java refers to them as pointers in one place, the NullPointerException). They are like pointers, except that the dangerous features are removed, namely:

The safety comes with a cost. Here’s my take on what happened. Originally Java’s references were called pointers. However, the term pointer had a bad rap from what chaos happens when you allow pointer arithmetic, optional initialisation and manual object recycling.

So they decided to rename them references. But old habits die hard and people, even those at Sun, sometimes continued to call them pointers. The further wanted a new term that allowed for the many ways you can implement Java pointers e.g. via machine virtual RAM pointers, segmented pointers, 64-bit addressing pointers or handles. The word pointer leaked through in various places including NullPointerException.

No More Pointers?

It depends whom you ask.
Most studies agree that pointers are one of the primary features that enable programmers to inject bugs into their code. Given that structures are gone and arrays and strings are objects, the need for pointers to these constructs goes away. Thus, Java has no pointer data types. Any task that would require arrays, structures and pointers in C can be more easily and reliably performed by declaring objects and arrays of objects. Instead of complex pointer manipulation on array pointers, you access arrays by their arithmetic indices. The Java run-time system checks all array indexing to ensure indices are within the bounds of the array.

You no longer have dangling pointers and trashing of memory because of incorrect pointers because there are no pointers in Java.
~ James Gosling (1955-05-18 age:62), co-inventor of Java, in a paper The Java Language Environment co-authored with Henry McGilton

An object is a class instance or an array.
The reference values (often just references) are pointers to these objects and a special null reference, which refers to no object.
~ James Gosling (1955-05-18 age:62), co-inventor of Java,

This page is posted
on the web at:


Optional Replicator mirror
of mindprod.com
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number