How I can return generic type from method? I wrote like this, but it dont work:
private static JsArray<T> convertListToJsArray(Collection<T> list)
I need to get Collection as parameter, and return parametrized JsArray.
How I can return generic type from method? I wrote like this, but it dont work:
private static JsArray<T> convertListToJsArray(Collection<T> list)
I need to get Collection as parameter, and return parametrized JsArray.
You must specify the type parameter in front of the return type:
private static <T> JsArray<T> convertListToJsArray(Collection<T> list) {}
You need to declare the T
type. This should work (notice the extra <T>
before your return type):
private static <T> JsArray<T> convertListToJsArray(Collection<T> list)