title: Roll dice and count arrays beginner
body: <p>I want to make a simple program that rolls a dice 1000 times and counts the amount of times each number 1-6 appears. It works fine but there is an error at the end.Why is it happening?</p>
  
  <pre><code>public class diceRollerCounter {
      public static void main(String[] args) {
          int dice [] = new int[7]; 
          for(int x = 0 ; x &lt;1000; x++ ) {
              ++dice [(int)(Math.random()*6+1)];
          }
          System.out.println("Number       Frequency" );  
          for(int index = 0; 1 &lt; dice.length ; index++) {
              System.out.println(index + "            " + dice[index]);
          }
      }
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>Number       Frequency
  0            0
  1            170
  2            143
  3            188
  4            165
  5            173
  6            161
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7
      at diceRollerCounter.main(diceRollerCounter.java:20)
  </code></pre>