我正在尝试将字符串pprice转换为浮点数。然而,该对象的price属性(浮点类型)被设置为0.00。请问有人能告诉我哪里出了问题吗?
String pprice="60.0"
String tokens[]=pprice.split(".");
if(tokens.length>=2)
{
int a=Integer.parseInt(tokens[0]);
int b=Integer.parseInt(tokens[1]);
float a1=(float)a;
float b1=(float)b;
Float price=a1+(b1/100);
prod.setProductPrice(price);
}
else if(tokens.length==1)
{
int a=Integer.parseInt(tokens[0]);
float a1=(float)a;
prod.setProductPrice(a1);
}