title: Java - Association, Composition, Aggregation
body: <p>I am new to java and programming overall, today I encountered a problem with these 3 relations. Unfortunately from my materials I can't understand how to implement them. I hope somebody can make this clear for me.</p>
  
  <p>1) Association
  For example I have 2 classes. Student and School, this is association with multiplicity 1:1, I understand that in each class, I'll have atribute that refers to the other class. But my question is, if In constructor do I declare these reference variable? Do I also create set and get methods for them? What if that association is with multiplicity 1:N ? I have reference variable, that refers to list, do i declare that somehow in constructor too? Do i create set and get methods for that array list?</p>
  
  <p>2) Aggregation
  From what I understand, in terms of implementation in Java aggregation is nothing but one-way association. So the reference variable is only in one class. Is my hypothesis true?</p>
  
  <p>3) Composition
  I know that composition is special type of aggregation. So what I think, in terms of implementation in Java, that it'll be one way association too, so the implementation will be same and the only thing that differs is how we recognize this relation outside of programming.</p>
  
  <p>If anybody could help me I would really appreciate it</p>
  
  <p>Sorry that I didn't show any example, true is that It would help me to describe my thoughts.</p>
  
  <p>Lets say we have class, student</p>
  
  <pre><code>public class Student {
      private String name;
      private School school;
     }
     public Student(String namei, School school) {
         this.name = name;
         this.school = school;
      }
  </code></pre>
  
  <p>If class school, would have an atribute private Student student, it would be an association. But if not, and the only reference atribute would be in class Student, Am I right if I would say that the relation between those classes is Aggregation ? </p>
  
  <p>What if we change it up a little bit and we say, that school, needs to have students. So the only thing we change would be the context, how we think about the subject and nothing else, if we would do that, Would I be right if I would say that the relation would be Composition?</p>