Register now or log in to join your professional community.
If we use pointer then in which way we used
The term "pointer" is strongly associated with the C/C++ concept of pointers, which are variables which explicitly store memory addresses, and which can be modified arithmetically to point to any arbitrary address. In Java, pointers exist, but not as a first-class language concept. Rather, pointers only exist as an implementation detail for References. The spec says:
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.
It's also telling that accessing a null reference throws a NullPointerException, not a NullReferenceException. So, clearly the Java designers were at least thinking in terms of pointers when they wrote the Java language spec. (Although really it should be called a NullReferenceException; in my opinion the name of that exception leaks through the abstraction)
Java does not support pointers which deals with memory directly , where in java takes care of memory allocation automatically , so you dont worry about using pointers
Pointer is reference handle to memory location. Improper handling of pointer leads to memory leakage and reliablity issues hence java doesn't support usage of pointer.
This was an intentional decision by the creators of Java, because most people would agree that having pointers creates a lot of potential for bugs in the code – pointers can be quite confusing, especially to new programmers. If you need to use pointers, use objects.