java - <T>泛型为什么在Object[]的前面?为什么都是用t代替,下面的代码却报错?
大家讲道理
大家讲道理 2017-04-18 10:56:34
0
3
572

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
左手右手慢动作

Static methods cannot reference generics defined on the class, static generic methods should be used. You can use it in Object[]之前加<T>表示这是一个静态泛型方法。使用静态泛型方法要在List<T>前面加<T> as follows

    public static <T>  List<T> name() {
        List<T> list = new ArrayList<T>();
        return list;
    }
PHPzhong

...Generics are for definition, you need to specify the type when using them

小葫芦

There is an introduction in think in java

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template