Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CustomException extends Exception {
- public CustomException(String message) {
- super(message);
- }
- }
- public class Pr3b {
- public static void main(String args[]) {
- try {
- int age = -20;
- if (age < 0) {
- throw new CustomException("Age can't be negtive.");
- }
- System.out.println("Aeg:" + age);
- } catch (CustomException e) {
- System.err.println("Error:" + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement