java - Finding minimum value of my ArrayList of float values -
i'm having sorts of problems trying expected quite simple. have arraylist of float values, , want return minimum value in list float. expected work:
public float getmin(){ float min = collections.min(arrays.aslist(listofthings))); return min; }
but keep running loads of incompatibility problems.
what's efficient way of doing this?
thanks
if use collection generic, collection.min
returns object
should convert it.
do this:
object obj = collections.min(arraylist); float f = float.parsefloat(obj.tostring()); return f.floatvalue();
or define arraylist
arraylist<float>
and don't need convert it.
Comments
Post a Comment