J. E. N. I.
Contoh berikut ini menunjukkan bahwa method myMethod tidak menangani ClassNotFoundException.
class ThrowingClass { static void myMethod() throws ClassNotFoundException { throw new ClassNotFoundException(" just a demo ");
}
}
class ThrowsDemo { public static void main( String args []) { try { ThrowingClass. myMethod();
} catch( ClassNotFoundException e) { System. out. println( e);
}
}
}
2.5 Kategori Exception
2.5.1 Exception Classes dan Hierarchy
Seperti yang disebutkan sebelumnya, root class dari seluruh exception classes adalah Throwable class. Yang disebutkan dibawah ini adalah exception class hierarchy. Seluruh exceptions ini terdefinisi pada package java. lang.
Tabel 1.4. Exception Class Hierarchy
Pengenalan Pemrograman 2 8