I have searched for this, but unfortunately, I don\'t get the correct answer.
class Helper { public static T[] toArray(List list) {
This is due to type erasure. The generics are removed in compilation, thus the Helper.toArray will be compiled into returning an Object[].
Helper.toArray
Object[]
For this particular case, I suggest you use List.toArray(T[]).
String[] array = list.toArray(new String[list.size()]);