title: Java ArrayList trying to check if object with this name exists
body: <p>I'm having a bit of trouble in my head trying to solve this:
  I'm working on a "rankList", an arrayList made of "Score". Score it's the object that has the following atributes: name,wins,loses,draws. My class Ranking has an ArrayList of Score objects. To create a new Score object I just use the name (and set the rest to 0 since it's new). However I'm trying to check if the player's name it's already in rankList I don't have to create new but sum a win or lose or draw.
  I have been reading arround that I have to override equals then others say I have to override contains... It's getting a big mess in my head. My fastest solution would be to write an "for" that goes arround the arrayList and use the <code>getName().equals("name");</code> however this is getting too messi in my code. I have checkPlayer (if the palyer is in the list):</p>
  
  <pre><code> public boolean checkPlayer(String playerName) {
      for (int i = 0; i &lt; this.rankList.size(); i++) {
          if (this.rankList.get(i).getName().equals(playerName)) {
              return true;
  
          }
      }
      return false;
  }
  </code></pre>
  
  <p>then if I want to incrase the wins i have this :</p>
  
  <pre><code>public void incraseWins(String playerName) {
      if (checkPlayer(playerName)) {
          for (int i = 0; i &lt; this.rankList.size(); i++) {
              if (this.rankList.get(i).getName().equals(playerName)) {
                  this.rankList.get(i).setWins(this.rankList.get(i).getWins() + 1);
                  break;
              }
          }
      } else {
          createPlayer(playerName);
      //more for to get to the player i'm looking for...
          for (int i = 0; i &lt; this.rankList.size(); i++) {
              if (this.rankList.get(i).getName().equals(playerName)) {
                  this.rankList.get(i).setWins(this.rankList.get(i).getWins() + 1);
                  break;
              }
          }
  
      }
  </code></pre>
  
  <p>So i guess there is a better way to do this... :/ </p>