gpt4 book ai didi

java - 无返回类型的错误

转载 作者:行者123 更新时间:2023-12-01 07:40:04 25 4
gpt4 key购买 nike

嗨,我的方法中出现错误,指出我的方法没有返回类型,这很令人困惑,因为它有返回类型;

public double getPhoneRates() {

final int freeminutes=50;
double totalcharge;
double chargeperminute = 0.10;
double d = 0;

if(b.regularService() == true){
if(b.getMinutes()<=50)
return totalcharge=0;
else
d=b.getMinutes()-freeminutes;

d = d * chargeperminute;
return totalcharge= freeminutes +d;
}
}

最佳答案

试试这个:

public double getPhoneRates()
{
final int freeminutes = 50;
double chargeperminute = 0.10;
double d = 0;
if (b.regularService() == true)
{
if (b.getMinutes() <= 50) return 0; //return 0
else d = b.getMinutes() - freeminutes;
d = d * chargeperminute;
return freeminutes + d; //return result
}

return -1; //some default value
}

关于java - 无返回类型的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6115558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com