Implementing a stack using a linked list
<p>For my midterm practice I have to "Write the class MyStack that implements a stack using a linked list." But, I can't understand what its asking me to do. I believe I need to do a stack of my own, but the prof. wants me to use linklist. </p>

<p>Doesm't linklist implement a stack?</p>

<pre><code>import java.util.LinkedList;
import java.util.NoSuchElementException;

public class MyStack&lt;T&gt; implements Stack&lt;T&gt;
{
  // the ﬁeld
  private LinkedList&lt;T&gt; data = new LinkedList&lt;T&gt;();

  // there is no constructor but implement the methods
  // of the Stack interface below. Recall that a stack is a
  // LIFO (last in, ﬁrst out) data structure.
}

public interface Stack&lt;T&gt;
{
  // add an item
  void add(T item);

  // remove an item, throw NoSuchElementException if the queue is empty
  T remove();
  // get the ﬁrst element without removing it
  // throw a NoSuchElementException if the queue is empty

  T peek();

  // there is no constructor but implement the methods
  // of the Stack interface below. Recall that a stack is a
  // LIFO (last in, ﬁrst out) data structure.
}

public interface Stack&lt;T&gt;
{
  // add an item
  void add(T item);

  // remove an item, throw NoSuchElementException if the queue is empty
  T remove();

  // get the ﬁrst element without removing it
  // throw a NoSuchElementException if the queue is empty
  T peek();

  // get the size
  int size();

  // check if the queue is empty
  boolean isEmpty();

  // empty the queue
  void clear();
}
</code></pre>
