>Heres the logic.
>
[quoted text clipped - 7 lines]
>logic? How can I efficiently use both and other options if any, for
>best results?
Inheritance A -> B -> C won't work. C private B can't see. C package
A can see.
Putting A in a different package won't work. It will hide package
methods of C, but will also hide package methods of B. A can see
public methods of B and C though.
You create and interface for B that has only the methods you want A to
see in B. A politely refrains from direct access to B or C, only
going through interface references implemented only on B.
This does not prevent malicious use of methods, but provides some
control if you stick to the convention.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
> objectOfClassA can access methods/variables of objectOfClassB
> objectOfClassB can access methods/variables of objectOfClassC
> And objectOfClassA cannot access methods/variables of objectOfClassC
>
> How can I achieve the above?
Is this homework?
Anyhow. Place B and C in one package, and A in another. Implement C as a
non-public class.
> How can I efficiently use both and other options if any, for
> best results?
Efficiently? Best results? In what respect? Number of lines of code?
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Indudhar - 21 Oct 2005 00:21 GMT
Firstly thank you Roedy and Thomas for your replies. No this is not
homework, but this is work. I want to design something like this to
help us at my work. I want to design three groups of classes. groupA
<=> groupB <=> groupC groups talking to each other, but I want to
"programmatically" restrict access for groupA<=>groupC. We are
designing huge number of classes and 4 of us developers. We were just
sitting and discussing how we can do that and we had no idea. The only
way is, tell each of us just not do something like groupA<=>groupC even
though you can. Our web application uses Spring framework. Is there
something that we can use in Spring, to help us out with this?
Unfortunately we all are novices in Spring!! It was recommended that
we use it, and so we are in this together!!!
Patrick May - 21 Oct 2005 09:52 GMT
> We are designing huge number of classes and 4 of us developers.
This is a red flag. Why are you designing a "huge number of
classes" up front? What do you mean by "huge"? Often this happens
when someone decides to wrap every table in an existing database in
its own class. There are almost always better solutions.
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | The experts in large scale distributed OO
| systems design and implementation.
pjm@spe.com | (C++, Java, Common Lisp, Jini, CORBA, UML)