阅读背景:

为什么我必须转换为Generic Type T,即使我知道它正确返回?

来源:互联网 

My code:

private static <T> T get(Class<T> clazz) throws IllegalAccessException, InstantiationException {
        if (clazz.equals(String.class)) {
            return (T) new String("abc");//line x
        } else {
            return clazz.newInstance();
        }

    }
private static <T> T get(Class<T> cl



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: