File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is it not against OO concept? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is it not against OO concept?" Watch "Is it not against OO concept?" New topic

Is it not against OO concept?

Geethakrishna Srihari
Ranch Hand

Joined: May 25, 2005
Posts: 30
The following code compiles:
class A
private int i;
public void modifyOther(A a1)
a1.i = 20;

The object has permission to use other object's private member ; it might be of same class - but is it not against OO? But this code compiles?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Encapsulation in Java is class-based, not object based. C++ is the same way. Some languages -- Ruby, and Python, I think, too -- have object-based encapsulation. I don't think one is more object-oriented than the other, really.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Is it not against OO concept?
It's not a secret anymore!