In Java, when should I create a checked exception, and when should it be a runtime exception? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: When to choose checked and unchecked exceptions When should I create a checked exception, and when should I make a runtime exception? For example, suppose I created the following class: public class Account { private float balance; /* ... constructor, getter, and other fields and methods */ public void transferTo(Account other, float amount) { if (amount > balance) throw new NotEnoughBalanceException(); /* ... *