following is the code, when i am giving command java Test A then i am getting error NoClassDefFoundError and when i give command java Test S then error is ClassNotFound.
As per my knowledge if newInstance() is used and class is not found then ClassNotFound error should com
Why is there difference in the errors?
class Test {
public static void main(String[] args) throws Exception
{
System.out.println("In Main Method");
Object o = Class.forName(args[0]).newInstance();
System.out.println(o.getClass().getName());
}
}
class Student
{
}
class Teacher
{
}