I'd like to implement Stack
from scratch and encountered a problem. I feel like I'm writing the parameters for push
method wrong such as:
public void push(<T> foo){
myList.add(foo);
}
How else can I write the parameter when I'm not sure what type the foo
is going to be?
package Stack;
import java.util.*;
public class Stack<T> {
private List<T> myList;
public Stack(){
myList = null;
}
public boolean empty(){
return (myList == null);
}
public void push(<T> foo){
myList.add(foo);
}
}