Re: Question regarding Java's OOP implementation.



Hi,

what you proved with your code is the behaviour as it is specified. 'private' means that you cannot access the field from another class. It does not say that anything about different instances of the same class.

In fact, the problem of accessability is not as one-dimensional as the modifiers (from private to public) suggest. It has several dimensions:

(A) same class / subclass / different class
(B) same package / subpackage (which is not a concept that java supports (*)) / different package
(C) inner class / different class
(D) same instance / different instance
(E) friend class (unknown by java as well) / non-friend class
(F) ...


Of course the different options are not completely orthogonal, but there are much more potential combinations of access rights than just the 4 which java supports.

Ciao,
Ingo

(*) a.b.c has nothing to do with a.b.c.d

.



Relevant Pages

  • Re: Some understanding questions...
    ... > must be private? ... class that has same namespace or not. ... In Java you should be able to do so ... Since there's the notion of "package private" too as I ...
    (microsoft.public.dotnet.vjsharp)
  • Re: (OT) In search of a definition
    ... primarily works under Windows XP, I am in search of a "good ... a package was NOT part of the language. ... without looking for something to formulate a hostile response from. ... use in Java is the same as its use in C or other languages. ...
    (comp.lang.cobol)
  • Re: (OT) In search of a definition
    ... a package was NOT part of the language. ... without looking for something to formulate a hostile response from. ... use in Java is the same as its use in C or other languages. ...
    (comp.lang.cobol)
  • building java rpm
    ... I am trying to build a java rpm based on the nosrc.rpm from jpackage.org ... chmod -R u+w bin CHANGES COPYRIGHT javaws lib LICENSE man plugin ... This package contains source files for %. ...
    (Fedora)
  • Re: Quirk with generics
    ... One place this has happened was when I said a Java class cannot have two methods with the same signature and different return types, Joshua Somebody accused me of being wrong, and I quoted chapter and verse from the JLS proving that Joshua was the wrong one. ... #* Creating four new source files within the package. ... #* Deleting the project, its package, and the four source files. ... #my IDE potentially disturbing the way I'd had it (current ...
    (comp.lang.java.programmer)