floatValuepublic float floatValue()
Returns the value of this Integer as a float.Overrides:floatValue in class Number
Returns:the int value represented by this object is converted to type float and the result of the conversion is returned.
Returns the value of this Integer as a float.Overrides:floatValue in class Number
Returns:the int value represented by this object is converted to type float and the result of the conversion is returned.
Float temp1 = temp.floatValue();
Integer -> Float :
Integer temp = new Integer(100);
Float temp1 = new Float(temp.floatValue());
rinehart的答案中有一个小小的疏忽,float是基本类型,不能赋给Float对象。
temp1=temp1*0.1/60;
或temp1=temp1.0.1f/60f;
你先作完运算后,在转换成Float对象!
float temp = 100f;
Float temp1 = new Float(temp*0.1f/60f);
temp = Math.rint(temp*10)/10;