gpt4 book ai didi

java - 使用 def 异常无法转换为可抛出错误

转载 作者:行者123 更新时间:2023-11-30 11:17:29 25 4
gpt4 key购买 nike

<分区>

public class Odexception extends Exception {
double deficit;
Odexception(String msg,double def) {
super(msg);
this.deficit=def;
}
}


public void withdraw(double amt) throws odexception {
if(amt<=balance) {
balance=balance-amt;
} else {
throw new Odexception("Insufficient balance",amt-balance);
}
}

public static void main(string ar[]) {
try{
c[0].acc[0].withdraw(2000);
} catch(Odexception e) {
System.out.println(e.getMessage());
}
}

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