I have a list as follow:
List<Integer> arrInt={2,3,5};
I want to convert this arraylist to array float.
float[] result={2,3,5};
My code:
public float[] convertIntToFloat(List<Integer> arr)
{
List<Float> arrResult=new ArrayList<Float>();
for(int i=0;i<arr.size();i++)
{
float x=i;
arrResult.add(x);
}
float result[]=arrResult.toArray( new float[arr.size()]); //Error
return result;
}
But it display error in my code as above. Can you help me?
float[]instead of going throughArrayList<Float>?