ArrayList a = new ArrayList();
for(int i = 0; i < a.size(), i++)
{
fl开发者_C百科oat f = float(a.get(i)); // ERROR : cant convert Object to float
}
Processing is a simpler java, so you can use the java syntax:
ArrayList<Float> a = new ArrayList<Float>();
a.add(1.0f); // "Autobox" a float into a Float object, adding it to the array
for (int i = 0; i < a.size(); i++)
{
float f = a.get(i); // "Unbox" the Float object
}
Lookup autoboxing/unboxing.
Must not be .NET, otherwise would be i < a.count;
float f = (float)(a.get(i)); ??
精彩评论