0

When creating objects we write something like this:

in Java:

test t = new test();

in C++:

test *t = new test();

So if the t variable gets the address of the new object, does it mean that t in Java is actually pointer like in C++?

yshavit
  • 42,327
  • 7
  • 87
  • 124
plumber
  • 33
  • 3
  • 2
    yes, the objects are really pointers to objects – Kevin Seifert Mar 10 '15 at 20:14
  • Yes. It is a pointer to an Object child. – avk Mar 10 '15 at 20:15
  • 5
    To those answering an unqualified "yes," keep in mind that a pointer in C++ can do things that a Java reference can't (like pointer arithmetic, or pointing to a primitive) and so the answer is actually much closer to "kinda" then just plain "yes." – yshavit Mar 10 '15 at 20:17

1 Answers1

1

Yes, it's a kind of pointer, called reference in Java. However, it's not identical to a C++ pointer.

Community
  • 1
  • 1
Emil Laine
  • 41,598
  • 9
  • 101
  • 157