• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing object directly  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In java why an actual object of a particular class can be accessed only through a reference to that object? Why cant we get an actual object of a class, why it has to be accessed only by the pointer to that object?
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mostly to get rid of working with explicit pointers and references, I would guess. Because Java gets rid of all the crappy dereference and alias operators, it's become a much more clear language.

Most of the time you want to work with references rather than objects anyway. Look at how full C++ libraries are with the & operator.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!