title: Field assignment in a Java foreach declaration
body: <p>I know that the foreach loop used in the following example doesn't compile. But does anybody know why using a field in a foreach loop declaration isn't allowed?</p>
  
  <pre><code>public class Foo {
      private Object obj;
  
      public void run(List&lt;Object&gt; objects) {
          for (obj : objects) {
              process();
          }
      }
  
      private void process() {
          // do something with obj
      }
  }
  </code></pre>