title: Java - LinkedList push() pop() implies it is a stack, not a queue?
body: <p>In my data structures class, I learned that a <code>LinkedList</code> is a queue. Like a line in real life, the first person who gets into the line will be the first person who leaves. Makes sense. As seen below, a <code>ListedList</code> implements a <code>Queue</code> which has a FIFO (first in first out) procedure. </p>
  
  <p>But if you look at the descriptions for the methods <code>push(E)</code> and <code>pop()</code>, they read as follows:</p>
  
  <p>push(E)</p>
  
  <blockquote>
    <p>Pushes an element onto the stack represented by this list. In other words, inserts the element at the front of this list.</p>
  </blockquote>
  
  <p>pop()</p>
  
  <blockquote>
    <p>Pops an element from the stack represented by this list. In other words, removes and returns the first element of this list.</p>
  </blockquote>
  
  <p>That's.... not a queue. That's a stack. The first element that goes into the LinkedList via <code>push</code> cannot be accessed by <code>pop</code> until every element added after it has been <code>pop()</code>'ed.</p>
  
  <p>Why is this? I get that LinkedLists can be both used as a stack (if you only use <code>addFirst(E)</code> and <code>removeFirst()</code>) and can be used as a queue (if you only use <code>addFirst(E)</code> and <code>removeLast()</code> or vice versa) so why is it like this? I feel like <code>pop()</code> should remove and return the last element, OR <code>push(E)</code> should add the element at the end of the <code>LinkedList</code>. Then it would make more sense. </p>
  
  <p>TLDR: Why does <code>LinkedList</code>'s <code>push</code> and <code>pop</code> imply it works as a stack when <code>LinkedList</code> actually implements <code>Queue</code> instead.</p>
  
  <p><a href="https://i.stack.imgur.com/epdYb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/epdYb.png" alt="enter image description here"></a></p>