Below are 2 code snippets
The first one uses ClassLoader class to load a specified class
ClassLoader cls = ClassLoader.getSystemClassL
ClassLoader.loadClass()
uses the specified classloader (the system classloader in your case), whereas Class.forName()
uses classloader of the current class.
Class.forName()
can be used when you don't care about particular classloader and want the same classloading behaviour as for statically referenced classes.