So I'm completely stumped..
this is the goal:
1. Start a new class named GenericStack that specifies a type variable that provides for generics.
2. Declare a linked list that will hold the elements in the stack, then use the linked list to implement the methods shown above (which is push(),pop(),peek(),size().
And this is all I got so far and need help:
import java.util.LinkedList; import java.util.Scanner; public class GenericStack<E> { private LinkedList<E> list = new LinkedList<E>(); public void push(E item) //the parameter is an item of type E { //list is our linked list, put the new item at the end list.add(item); } public void pop(E item) { list.remove(); } public void peek(E item) { list.peek(); } public int size(E item) { return list.size(); } }
and then: