title: how arrayDeque.peek() Method in java working with while loop
body: <pre><code>    import java.util.ArrayDeque;
  
  class Main {
      public static void main(String[] args) {
          ArrayDeque&lt;Integer&gt; arrayDeque = new ArrayDeque&lt;&gt;();
          arrayDeque.push(10);
          arrayDeque.push(11);
          arrayDeque.push(15);
          arrayDeque.push(20);
          arrayDeque.push(200);
          arrayDeque.add(700);
          while (arrayDeque.peek() != null) {
              System.out.println(arrayDeque.pop() + " ");
          }
      }
  }
  </code></pre>
  
  <p>Good Day .. I have a question regarding the peek() method in ArrayDeque Class .. all the method will do is retrieve the head of the arrayDeque without removing it. so if that is the case how it's working perfectly without going for an infinite loop .. I mean who told the Method to look for the Next element after each complete loop.</p>