title: Comparing objects never returns true
body: <p>I'm trying to compare two objects of the same type (in method doesHave), but I've never got "true" returned. Here's my code:</p>
  
  <pre><code>private ArrayList&lt;Osoba&gt; osoba = new ArrayList&lt;Osoba&gt;();    
  
  public boolean doesHave(Osoba o) {
          for (int i = 0; i &lt; osoba.size(); i++) {
              if (pobierz(i).equals(o))
                  return true;
          }
          return false;
      }
  
  public Osoba pobierz(int index) {
              return osoba.get(index);
          }
  </code></pre>
  
  <p>The 'Osoba' class, looks like this:</p>
  
  <pre><code>public class Osoba {
      private String imie;
      private String nazwisko;
  
      public String toString() {
          return imie + " " + nazwisko;
      }
  
      public Osoba(String name, String surname) {
          imie = name;
          nazwisko = surname;
      }
  
      public String getImie() {
          return imie;
      }
  
      public String getNazwisko() {
          return nazwisko;
      }
  }
  </code></pre>
  
  <p>Code from main:</p>
  
  <pre><code>Osoba osoby = new Osoba(name, surname);
  if (kartoteka.doesHave(osoby) == Boolean.TRUE) {
              temp = odczyt.nextLine();
              if (temp.equals("y"))
                  kartoteka.usun(osoby); //some method
              else
                  ...
          }
  </code></pre>
  
  <p>No matter what input I'd use, this part never happens. 
  'kartoteka' is my package which of course I have imported. Each class is in separate package, but there is no problem with using them. I've tried googling it for quite some time, but nothing helped me, it just seems like </p>
  
  <pre><code>if (kartoteka.doesHave(osoby) == Boolean.TRUE)
  </code></pre>
  
  <p>Is never true, but I have no idea why. Code without Boolean.TRUE doesn't work as well. If I could get some hints, I'd be thankful. Sorry for asking that kind of question, but I'm new in java.</p>