println 怎么可能在 void 方法中工作?

How is it possible that println works inside void method?

public void debit (double amount){
    if (balance<amount){
        System.out.println("Amount withdrawn exceedes the current balance");
    }
    else {
        balance-=amount;
    }
}

当我在 main 中调用 toString 时,我收到消息 "Amount withdrawn exceedes the current balance",然后是 toString 内容。方法无效怎么可能?

它不会 return 任何调用您的方法的方法。只需将您的消息打印到屏幕上。就这么简单:)