> Hi,
>
[quoted text clipped - 4 lines]
>
> Thank you very much.
class A {
private B b;
public B getB() {
return b;
}
}
class B {
private A a;
public A getA() {
return a;
}
}
Pretty simple.
> Hi,
>
> I saw a UML diagram showing two classes A and B. A "has a" B in it. B
> "has a" A in it. I feel hard to understand.
>
> Could you help me or give me some code to show that concept?
The thing to remember is that "has a" really means
"has a reference to a."
You give your friend a piece of paper with your telephone
number, and she gives you a piece of paper with hers. Neither
of you has swallowed the other, and there's no crazy infinite
recursion of mutual swallowing: Each of you walks away with
piece of paper, and each has the ability to call the other.

Signature
Eric Sosman
esosman@acm-dot-org.invalid