In Java, pointers play an important role behind the scenes in the form of references to objects. A Java variable of object type stores a reference to an object, which is just a pointer giving the address of that object in memory. When you use an object variable in a program, the computer automatically follows the pointer stored in that variable in order to find the actual object in memory. Since all this happens automatically, behind the scenes, you really don't have to worry much about the fact that objects are referenced through pointers.
Some variables can store pointers, but only variables that are of special pointer types .
Another operator, named delete is provided for doing this. When you use ptr in a program, you are referring to the actual pointer, that is, the memory address that is contained in the variable ptr . The type of a subroutine parameter can be a pointer type. For example, here is a subroutine that will swap the integer values stored in two memory locations. Suppose that x is any variable.