有如下java代码:
1 2 3 4 5 6 7 |
|
问:该段代码报错,提示返回的类型应该是Object[],怎么才能返回T[]?
阿神2017-04-17 15:08:51
return set.toArray(arr1);
toArray()
The method is also generic, and the return type is consistent with the parameter type. Yours is an Object
array, of course it won’t work.