• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java references??  RSS feed

 
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So coming from studying c++ for a couple of months and doing some research I've come to the conclusion that references are similar to pointers in c++(yes have some differences) but I want to know how to use them because I'm a little bit confused





so one is a reference?? pointing to an object?
also two is a reference not an object pointing to the object one?

Thanks
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're intimately familiar with C++, you can imagine that all of Java's reference types are actually pointers. The main difference is that you cannot perform pointer arithmetic, and dereferencing happens implicitly. The snippet of code you posted is similar to:

Now, imagine you did the following in Java:
It would be the same as doing the following in C++:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!