title: Java for loop through array list returns out of order
body: <p>Sorry for weird wording of the title, here's my problem: I'm making a game in a java, and I have a Model Library class which loads all the models in a specific folder to an array list of models. The code I have works just fine for loading the models, but the problem is getting a model with a specific name from an Array List.</p>
  
  <p>I use:</p>
  
  <pre><code>public RawModel getModel(String name){
      for(int i =0;i&lt; modes.size();i++){
          System.out.println((i+1)+". Comparing " + name + " with " + modes.get(i).getName());
          if(modes.get(i).getName() == name){
              System.out.println("Returned model " + modes.get(i).getName());
              return modes.get(i);
  
          }
      }
      System.err.println("Returned default Model");
      return modes.get(0);
  }
  </code></pre>
  
  <p>which in theory SHOULD work with getting the model with the said name, but in the console it returns this:</p>
  
  <pre><code>1. Comparing platform.river with cube
  Returned default Model
  Returned default Model
  2. Comparing platform.river with grenade
  3. Comparing platform.river with plasma
  4. Comparing platform.river with platform.river
  5. Comparing platform.river with waterhole
  1. Comparing cube with cube
  2. Comparing cube with grenade
  3. Comparing cube with plasma
  4. Comparing cube with platform.river
  5. Comparing cube with waterhole
  1. Comparing waterhole with cube
  2. Comparing waterhole with grenade
  3. Comparing waterhole with plasma
  4. Comparing waterhole with platform.river
  5. Comparing waterhole with waterhole
  Returned default Model
  </code></pre>
  
  <p>It doesn't seem to complete the loop before returning null! Then in the second one it seems to have skipped the loop entirely, then the third one seems to have returned null after looping. Is there a better way to get a model with the said name? How can I fix this issue?</p>