Friday, May 29, 2015

ClassNotFoundException v/s No ClassDefFoundError

Test t = new Test()
if classname is hardcoded then if at runtime the .class file is nt available then will get NoClassDefFoundError

NoClassDefFoundError -- is unchecked exception bocz it is Error


Object o= Class.forName(args[0]).newInstance()
Java Test Student

at runtime for dynamically  provided class name, if the corresponding .class file is nt avalible then will get  ClassNotFoundException

ClassNotFoundException --> is a checked exception

No comments:

Post a Comment