title: indexOf() for ArrayList of user defined objects not working
body: <p>I am not getting the right answer when I try to use indexOf() of an ArrayList made up of user defined objects. Here is the code that creates one of the objects:</p>
  
  <pre><code>    State kansas = new State("KS", 5570.81, 2000)
  </code></pre>
  
  <p>So, the name of the object is "kansas"</p>
  
  <p>Here is the code that creates the ArrayList and adds the object: </p>
  
  <pre><code>    ArrayList&lt;State&gt; allStates = new ArrayList&lt;State&gt;();    
      allStates.add(kansas);
  </code></pre>
  
  <p>And here is the code that I try to use to find the index of this object: </p>
  
  <pre><code>    System.out.println(allStates.indexOf(kansas));
  </code></pre>
  
  <p>This is the point at which my compiler (Eclipse) throws me a red X indicating that there is a problem with my code and the problem is that it does not recognize 'kansas'. So I tried this: </p>
  
  <pre><code>    String s = "kansas";
      System.out.println(allStates.indexOf(s));
  </code></pre>
  
  <p>and it will run but the result is -1.</p>
  
  <p>I am calling a method from a different class to create the ArrayList as opposed to creating it in the same class as my main method but I'm new enough to coding that I"m not sure if that is where I am going wrong. However, in order for the program that I am writing to work, I need to have data about each of the State objects stored so that I can access it from the main method. </p>
  
  <p>Any advice? </p>
  
  <p>*This is my first time posting a questions and I wasn't sure how much detail to go into so if I'm missing relevant information please let me know :)</p>