title: How to check ALL elements of a boolean array are true
body: <p>I have a boolean array whose size depends on the size of a randomly selected string.</p>
  
  <p>So I have something like this:</p>
  
  <pre><code>boolean[] foundLetterArray = new boolean[selectedWord.length()];
  </code></pre>
  
  <p>As the program progresses, this particular boolean array gets filled with true values for each element in the array. I just want to print a statement as soon as all the elements of the array are true. So I have tried:</p>
  
  <pre><code>if(foundLetterArray[selectedWord.length()]==true){
      System.out.println("You have reached the end");
  }
  </code></pre>
  
  <p>This gives me an out of bounds exception error. I have also tried <code>contains()</code> method but that ends the loop even if 1 element in the array is true. Do I need a for loop that iterates through all the elements of the array? How can I set a test condition in that?</p>