Eclipse Generic Warning:类型安全:未选中从T到E的强制转换

时间:2015-04-14 20:44:59

标签: generics unchecked-cast

如何避免以下代码中的通用警告? Eclipse Generic Warning:类型安全:未选中从T转换为E

有没有办法改进此代码。只需在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();
}

0 个答案:

没有答案
相关问题