BOUtils.java的功能是返回一个四舍五入的Double类型的数值package my;
public class BOUtils {
public Double getRoundedDouble( double unroundedValue ){
double intPortion = Math.floor( unroundedValue );
double unroundedDecimalPortion = ( unroundedValue - intPortion );
double roundedDecimalPortion = Math.round( unroundedDecimalPortion * 100 );
roundedDecimalPortion = roundedDecimalPortion / 100;
double total = intPortion + roundedDecimalPortion;
return new Double( total );
}
}我的jsp文件如下,但在eclipse中出现红色的下划线,
说:“Type mismatch: cannot convert from Double to double”
<jsp:useBean id="BO" scope="application" class="my.BOUtils"/>
<%
double[] bn= new double[30];
bn[0]=BO.getRoundedDouble(33.333);
%>
请高手帮我解决
public class BOUtils {
public Double getRoundedDouble( double unroundedValue ){
double intPortion = Math.floor( unroundedValue );
double unroundedDecimalPortion = ( unroundedValue - intPortion );
double roundedDecimalPortion = Math.round( unroundedDecimalPortion * 100 );
roundedDecimalPortion = roundedDecimalPortion / 100;
double total = intPortion + roundedDecimalPortion;
return new Double( total );
}
}我的jsp文件如下,但在eclipse中出现红色的下划线,
说:“Type mismatch: cannot convert from Double to double”
<jsp:useBean id="BO" scope="application" class="my.BOUtils"/>
<%
double[] bn= new double[30];
bn[0]=BO.getRoundedDouble(33.333);
%>
请高手帮我解决
Double 是 JAVA 类库中的一个类型,是引用类型。值类型和引用类型分不清,楼主快完蛋了。:)BO.getRoundedDouble(33.333).doubleValue();