Static Vs Dynamic class loading in Java
The class loader concept, one of the cornerstones of the Java virtual machine (JVM). It describes the behaviour of converting a named class into the bits responsible for implementing that class. Because class loaders exist, the Java run time does not need to know anything about files and file systems when running Java programs.
Static class loading
In static class loading Classes are statically loaded with Java’s "new" operator. In this case, the retrieval of class definition and instantiation of the object is done at compile time.
Dynamic class loading
Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time. Dynamic class loading is done when the name of the class is not known at compile time.
Syntax
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.
The Java model loads classes as needed and need not know the name of all classes in a collection before any one of its classes can be loaded and run.