What Is Pointer?

First of all, what is Pointer? of course, here we are talking about pointer in the computer programming terms. A pointer basically is a variable which holds the address of another value located in the computer memory. It holds the address of other variable of the specified data type like int, float & char.

A pointer references a location in the memory, and obtaining the value which is stored in that location is known as dereferencing the pointer.

Let me tell you a simple analogy of pointer. A page number in a book’s index could be considered to be a pointer into that matching page. And dereferencing the pointer (in this case the page number) can be done by flipping to the page destination.

A pointer variable is declared with a ‘*’ before it. Here’s an example :

int *a=&b it is actually a simple notation from,
int *a;
‘*’ is used to dereference a pointer. A pointer on dereferencing goes to the pointing address and looks for the value it is holding.

A pointer is a more concrete, simple implementation of the reference data type which is more abstract. Some languages, especially low-level programming languages support some kind of pointer.

Who Created Pointer?

Pointer is invented by this man called Harold Lawson around 1964. And in the 2000, the IEEE presented the Computer Pioneer Award to Harold Lawson, “for inventing the pointer variable and introducing this concept into PL/I, thus providing for the first time, the capability to flexibly treat linked lists in a general-purpose high level language”. (As quoted by Wikipedia).

Does Java Have Pointer?

Unlike C, C++, or Pascal, there is no explicit representation of pointers in Java. Java does not provide any explicit pointer manipulation operators. 

Some reason to why Java doesn’t have pointer :

  • Unsafe memory access via pointers. Giving trouble to the JVM garbage collector.
  • Bad for security and disrupts the basis of OOP.

It is still possible to dereference a null reference (null pointer), but, it can result in a run-time exception being thrown. The space that’s occupied by unreferenced memory objects is recovered automatically by garbage collection at run-time.

Published by

Rafif Santika

The programming language that I specialize in is Java, because I think Java programming language is more universal and of course because I like it regardless of any reason.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.