Hi,
I don't really understand your questions, and I think this is because your understanding of what your code is supposed to do is flawed. I'll explain what the methods
really do, and then you might want to ask a follow-up question.
Class.forName() returns a Class object representing the named class. It uses the "context ClassLoader" for the calling
thread to find this Class object, which, all things being equal, is the system ClassLoader.
The ClassLoader, in turn, will first check to see if the class has already been loaded; if it has, it will return that Class object. Otherwise, it will look on disk for the .class file corresponding to that named class.
Note that the system ClassLoader can only load existing .class files. It cannot create any new classes out of thin air.
Any one ClassLoader can only load a given class
once. The only way that a class can be "unloaded" is for the ClassLoader object that loaded it to itself be garbage-collected first. This obviously never happens with the system ClassLoader. To "reload" a class, you have to explicitly create a new ClassLoader and load the class through that new loader.
The newInstance() method of Class creates an instance of the given class cia the class's no-argument constructor. The following two lines:
are precisely equivalent to this one line
So, there you have it. If this doesn't clear things up, feel free to ask another question in this thread. You can also check out
Ted Neward's wonderful paper on this topic.