Can you explain how can we practically do dynamic loading?
Classloader and its method LoadClass() is used for dynamic loading of a class. It is an important feature of JVM as it provides facility to install software component at run time. It has number of characteristics like the classes are loaded on demand and it maintains the type safety of JVM.
For Examplepublic class loadClass
{
public static void main(String args[])
{
ClassLoader classloader= loadClass.class.get ClassLoader()
try
{
Class aClass= classloader.LoadClass(“com.program.MyClass”);
System.out.println (“aClass.getName()=”+ aClass.getName());
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
}
}