java.math.bigdecimal cannot be cast to ljava_JFinal:java.math.BigDecimal cannot be cast to java.lang...

@JFinal 你好,想跟你请教个问题:

我在做一个购物车测试功能,小计金额时报错如下:

java.math.BigDecimal cannot be cast to java.lang.Float

数据后台的表price字段的类型如下:

Name      Type         Length        Decimals

price       decimal      10                2

qty的int型与price中的Float型相乖报错,应如何解决?,thks.

public class Gallery extends Model {

public static final Gallery dao=new Gallery();

}

package com.demo.car;

import com.demo.gallery.Gallery;

public class CarItem {

private Gallery gallery;

private int qty;

private float totalPrice;

public CarItem(Gallery gallery,int qty){

super();

this.gallery=gallery;

this.qty=qty;

}

public Gallery getGallery() {

return gallery;

}

public void setGallery(Gallery gallery) {

this.gallery = gallery;

}

public int getQty() {

return qty;

}

public void setQty(int qty) {

this.qty = qty;

}

public float getTotalPrice() {

this.totalPrice=this.qty*this.gallery.getFloat("price"); // 此处报错

return totalPrice;

}

public Float getPrice(){

return this.gallery.getFloat("price");

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值