Professional Documents
Culture Documents
Module 9 Exceptions Introduction to Exceptions Exception handling in Java User defined exceptions Assertions
T5: Demo
Cch s dng:
int temp; try { System.out.println("Enter new capacity of the hotel:"); temp = input.nextInt(); if(temp <= 0) { throw new MyDemoException(0); } } catch (MyDemoException e) { System.out.println("Enter a non-zero positive number"); }