I am unable to provide values of type int[]
, float[]
, etc. to a generic function. I get errors that say basically that float[]
is the wrong type and Float[]
is what the function actually takes.
Here's an example of a method I wrote, and I'm trying to give it values like new int[]{0,1}
(created in library somewhere else).
private static <T> JSONArray encodeArray(T[] array) {
JSONArray arr = new JSONArray();
Collections.addAll(arr, array);
return arr;
}
Is it even possible to write my function signature to accept these arrays of literals?
I could go to the call site, and do a conversion of float[]
to Float[]
, but I don't know how to do that either.