title: PMD: Avoid instantiating new objects inside loops
body: <p>I've got an issue with the PMD rule <code>Avoid instantiating new objects inside loops</code>. Here is some example code:</p>
  
  <pre><code>import java.awt.Dimension;
  
  public class PMDDemo {
      public static void main(final String[] args) {
          final Dimension[] arr = new Dimension[10];
          for (int i = 0; i &lt; arr.length; i++) {
              arr[i] = new Dimension(i, i); // rule violation here
          }
      }
  }
  </code></pre>
  
  <p>PMD gives me the above mentioned rule violation at the marked spot in the code. How am I supposed to create <em>n</em> instances of a class without creating them within a loop?</p>
  
  <p>I know that some of PMD's rules are controversial (like the <em>onlyOneExit</em> rule). But up to now I at least understood the idea behind them. I don't understand the reasoning behind this rule. Can someone help me with that?</p>