Java Pointers

No Pointers!

The Java language does not have pointer types nor address arithmetic. Java
variables are either primitive types or references to objects. To illustrate the
difference between C/C++ and Java semantics, consider the following equivalent
code fragments.
// C++ code (C code would be similar)
Stack *s = new Stack; // point to a new Stack
s->push(...);
// dereference and access method push()
The equivalent Java code is:
// Java code
// internally, consider s to be a (Stack *)
Stack s = new Stack();
// dereference s automatically
s.push(...);

  © Free Blogger Templates Modic Template by For more Information : click Here

Back to TOP