Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time. Let us look at how to load
classes dynamically by using Class.forName (String className); method, it is a static method.
The above static method returns the class object associated with the class name. The string className can be supplied dynamically at
run time. Once the class is dynamically loaded the class.newInstance () method returns an instance of the loaded class. It is just like
creating a class object with no arguments.
A ClassNotFoundException is thrown when an application tries to load in a class through its class name, but no definition for the class
with the specified name could be found.
|