Code example for Deque

Methods: isEmpty, peek

0
  public int peek() throws IOException { 
    if (isFinished()) { 
      throw new IllegalStateException("Peek called after end of file.");
    } 
     
    return stack.peek();
  } 
   
  public void pop() throws IOException { 
    stack.pop();
     
    if (stack.isEmpty()) {
      readIntoStack(); 
    } 
  } 
   
  public boolean isFinished() { 
    return endOfFile && stack.isEmpty();
  } 
 
  public void close() throws IOException { 
    reader.close();
  }