How I can avoid generic warnings in the following code? Eclipse Generic Warning : Type safety: Unchecked cast from T to E
Is there a way to improve this code. Just putting and removing values from Stack.
public static <T, K, E> void genericStack(T a, K b) {
Stack<E> st = new Stack<E>();
st.push((E) a);
st.push((E) b);
b = (K) st.pop();
a = (T) st.pop();
}