title: Accessing Vector from another class
body: <p>I have these two classes, named Student and Subject</p>
  
  <pre><code>import java.util.Vector;
  
  public class Student
  {
      int registrationNumber;
      String firstName;
      String familyName;
      Vector&lt;Subject&gt; sub;
  
      public Student(int registrationNumber,String firstName, String familyName, Subject sub) {
         this.registrationNumber = registrationNumber;
         this.firstName = firstName;
         this.familyName = familyName;
         this.sub = new Vector&lt;Subject&gt;();
      }
  
      public Vector&lt;Subject&gt; getSub(){
        return sub;
      }
  }
  </code></pre>
  
  <p>and </p>
  
  
  
  <pre><code>int subjectNumber;
  Vector&lt;Double&gt; homeworkMark;
  Vector&lt;Double&gt; examinationMark;
  
  public Subject(int subjectNumber) {
      this.subjectNumber = subjectNumber;  
      this.homeworkMark  = new Vector&lt;Double&gt;();
      this.examinationMark = new Vector&lt;Double&gt;();
  }
  
  
  public double homeworkAverage() {
      double homeworkAddition = 0;
      for(Subject y: getSub()){
         for (double s: homeworkMark) {
            homeworkAddition += s;
         }
      }
      return homeworkAddition;
  }
  
  public double examinationAverage() {
     double examAddition = 0;
     for(Subject y: getSub()){
       for (double s: examinationMark) {
            examAddition += s;
        }
     }
     return examAddition;
  }
  </code></pre>
  
  <p>I'm trying to use my getter method called <code>getSub()</code> to perform an addition of the Homeworks and exam marks in all the subjects the user enters, which are stored in the <em>sub</em> <code>Vector</code>. </p>
  
  <p>My problem is in this loop (also in the similar <code>examinationAverage()</code> method </p>
  
  <pre><code>public double homeworkAverage() {
        double homeworkAddition = 0;
        for(Subject y: getSub()){
           for (double s: homeworkMark) {
                homeworkAddition += s;
           }
        }
        return homeworkAddition;
   }
  </code></pre>
  
  <p>I tried creating an instance of student, though, it tells me that I have no arguments set, and that I cannot continue...</p>
  
  <p>Any Ideas,</p>
  
  <p>Thanks In Advance. </p>