title: Why is printing "B" dramatically slower than printing "#"?
body: <p>I generated two matrices of <code>1000</code> x <code>1000</code>:</p>
  
  <p>First Matrix: <code>O</code> and <code>#</code>.<br>
  Second Matrix: <code>O</code> and <code>B</code>.</p>
  
  <p>Using the following code, the first matrix took 8.52 seconds to complete:</p>
  
  <pre><code>Random r = new Random();
  for (int i = 0; i &lt; 1000; i++) {
      for (int j = 0; j &lt; 1000; j++) {
          if(r.nextInt(4) == 0) {
              System.out.print("O");
          } else {
              System.out.print("#");
          }
      }
  
     System.out.println("");
   }
  </code></pre>
  
  <p>With this code, the second matrix took 259.152 seconds to complete:</p>
  
  <pre><code>Random r = new Random();
  for (int i = 0; i &lt; 1000; i++) {
      for (int j = 0; j &lt; 1000; j++) {
          if(r.nextInt(4) == 0) {
              System.out.print("O");
          } else {
              System.out.print("B"); //only line changed
          }
      }
  
      System.out.println("");
  }
  </code></pre>
  
  <p>What is the reason behind the dramatically different run times?</p>
  
  <hr>
  
  <p>As suggested in the comments, printing only <code>System.out.print("#");</code> takes <code>7.8871</code> seconds, whereas <code>System.out.print("B");</code> gives <code>still printing...</code>.</p>
  
  <p>As others who pointed out that it works for them normally, I tried <a href="http://ideone.com" rel="noreferrer">Ideone.com</a> for instance, and both pieces of code execute at the same speed.</p>
  
  <p>Test Conditions:</p>
  
  <ul>
  <li>I ran this test from <em>Netbeans 7.2</em>, with the output into its console</li>
  <li>I used <code>System.nanoTime()</code> for measurements</li>
  </ul>