title: How to not consider duplicate value in a Table
body: <p>I'm implementing a JTable, where an user can define the TimeTable. 
  Every subject has a number of credits, and I have to count the sum of all credits in a week. Obviously, for do that it's necessary to count one time all duplicate subject(I would not count two time the credits of the same subject). </p>
  
  <p>For example, if the JTable is
  <img src="https://i.stack.imgur.com/gkMva.jpg" alt="Imagine of an example TimeTable"></p>
  
  <p>I would like to get the value <code>Math</code>,<code>English</code>,<code>Science</code>, <code>Philosophy</code>, <code>Art</code> only <strong>ONE</strong> time. I've tried to do this with the follower method:</p>
  
  <pre><code>private void getOnce (String[] dailyLessons)
  {   
      Set&lt;String&gt; weekSubjects = new HashSet&lt;String&gt;();
      int weeklyCredits=0;
  
          //dailylessons is a String[] that contains the lessons of the day
      Collections.addAll(weekSubjects, dailyLessons);
  
      //String[] week would contain every subject only one time
          String [] week = weekSubjects.toArray(new String[0]);
  
      //for all the subject I get its credits
      for (int i=0; i&lt;week.length; i++)
       {
          if (!week[i].equals("no"))
          {
              String [] credits= week[i].getCredits;
              weeklyCredits += credits;
          }
          }
  }
  </code></pre>
  
  <p>But it does not work. Could you explain me why? A correct version of my code will be very appreciated.</p>