2023年12月17日发(作者:)

java返回类型与不兼容_不兼容的返回类型错误javaclass BankAccount {private String firstname;private String lastname;private int ssn;private int accountnumber = 0;private double accountbalance = 0.0;BankAccount() {firstname = "John Smith";}BankAccount(String firstname, String lastname, int ssn) {int accountnumber;double accountbalance;}public String getName() {return firstname;}public double getBalance() {return accountbalance;}public void setAccountNumber(int accountnumber) {return accountnumber;}public boolean equals(BankAccount ba) {return tbalance == tbalance;}public void deposit(double amount) {return tbalance = tbalance + amount;}public int withdraw(double amount) {tbalance = tbalance - amount;if(accountbalance < 0) {tbalance = tbalance + amount;return -1;

}elsereturn 0;}public String toString() {return firstname+lastname+"/n"+"social secuirty "+"ssn"+"/n"+"account number is "+"accountnumber" +"/n" +"Balance:" +"accountbalance" +"/n";}}错误是::34: error: incompatible types: unexpected return valuereturn accountnumber;^:47: error: incompatible types: unexpected return valuereturn tbalance=tbalance+amount;^2 errors我做错了什么?