May 2001
Intermediate to advanced
1088 pages
30h 13m
English
Java's capability to load classes dynamically is one of the biggest boons for developers. Although it's true that other languages have had the capability to load dynamic libraries at runtime, none of them compare to the ease with which you can load a new Java class and create instances of that class.
To load a class dynamically, you only need to do the following:
Class someClass = Class.forName("foo.bar.SomeClass");
If you only need to use the default constructor for a class, you can use the newInstance method in the Class object:
Object someClassOb = someClass.newInstance();
If you need to invoke a static method on the object or call one of the other constructors, you must use Reflection (which you saw in Chapter ...
Read now
Unlock full access