See this code example :
List list = new ArrayList();
list.add("hello");
list.add("world");
Object [] array = list.toArray();
Why does the method toArray() return an array of Object ? Other List methods such as get() , remove() are able to return the type of objects in the list.
解决方案
Because array has been in Java since the beginning, while generics
were only introduced in Java 5. And the List.toArray() method was
introduced in Java 1.2, before generics existed, so it was
specified to return Object[].
u can use toArray(T[] a) just take a look Collection.toArray(T[] a)