问大家一个小问题?
有如下代码:
public java.lang.Float getTotalPrice() {
/**@todo Complete this method*/
System.out.println("\tgetTotalPrice():"+this);
float totalPrice=0f;
for(int i=0,n=_items.size();i < n; i++)
{
Item current=(Item)_items.get(i);
totalPrice+=current.getPrice();
}
return ((long)(totalPrice*100))/100f ; //line:60
}
出现如下错误提示:
Incompatible types;found float;required:java.lang.Float at line 60;
我已经加了java.lang.float;
但是就这一句: return ((long)(totalPrice*100))/100f
出现以上错误提示:
请问这有错吗?怎么改正呢?