I think probably this question has been asked/answered several times before my post. But I couldn't get the exact thing I am looking for, so I post it again:
I am trying to do like this:
float[][] fa2 = {{7,2}, {5,4}, {9,6}, {4,7}, {8,1}, {2,3}};
ArrayList<Float[]> AF = new ArrayList<Float[]>();
AF = Arrays.asList(fa2);
But it is giving an error:
Type mismatch: cannot convert from List<float[]> to ArrayList<Float[]>
I understand the reason for the error but what is the most convenient way to do the conversion in Java ?
This is the easiest way that I can think of. Is there something better / more convenient ?
float[][] fa2 = {{7,2}, {5,4}, {9,6}, {4,7}, {8,1}, {2,3}};
ArrayList<Float[]> AF = new ArrayList<Float[]>(fa2.length);
for (float[] fa : fa2) {
//initialize Float[]
Float[] Fa = new Float[fa.length];
//copy element of float[] to Float[]
int i = 0;
for (float f : fa) {
Fa[i++] = Float.valueOf(f);
}
//add Float[] element to ArrayList<Float[]>
AF.add(Fa);
}