This week's book giveaway is in the Performance forum. We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line! See this thread for details.
How do I get the name of the "className" initialized here from another class (both in the same package)? Class.forname("className").newInstance(); getClass().getName() gets the name of the class loaded. Thanks.
Peter den Haan
posted 15 years ago
Not sure what exactly you are asking... but are you looking for the class literal? TheClass.class.getName() will return "your.package.TheClass" and will instantiate TheClass if passed as argument to Class.forName(). - Peter