title: How to write Composition and Aggregation in java
body: <p>I want to know how to identify composition and aggregation code in java. I have C++ Code, But I don't understand how to write in java. </p>
  
  <p>Composition</p>
  
  <pre><code>class A {};
  class B { A composited_A; };
  </code></pre>
  
  <p>Aggregation via Pointer</p>
  
  <pre><code>class A {};
  class B
  {
  A* pointer_to_A;
  B(A anA){ 
  pointer_to_A = &amp;anA;
  }
  </code></pre>
  
  <p>Can anyone please tell me how both are working in JAVA. (I know what is meant by Composition and aggregation )
      };</p>