title: Java: perform for statement until given variable has reached a certain value?
body: <p>I want to have a <code>for</code> statement that repeats until a given <code>int</code> reaches a certain value.</p>
  
  <p>For example...</p>
  
  <pre><code>for (int variable = 0; variable &lt; other_variable; variable++) {
  </code></pre>
  
  <p>The problem with this is that the <code>for</code> statement will never end. It will continue to repeat endlessly. What have I done wrong?</p>
  
  <p>This is my code...</p>
  
  <pre><code>boolean itemexist_check = false;
  do {
      int i2 = m_area.m_items.size();
  
      for (int i = 0; i &lt; i2; i++) {
          String s2 = m_area.m_items.get(i).returnName();
          System.out.println("Checking...");
  
          if (s2.contains(s)) {
              System.out.println("You take the " + s2 + ".");
              itemexist_check = true;
              player.addItem(m_area.m_items.get(i));
              m_area.m_items.remove(i);
          }
          else {
              //do nothing, repeat loop
          }
      } 
  }
  while (itemexist_check == false);
  </code></pre>
  
  <p>In this code, <code>m_area.m_items.size()</code> would return <code>1</code>, so <code>i2</code> would be <code>1</code>.</p>