This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
hiiiii.... as far as Class.forName() is concerned it is used to load a class at runtime. i.e. at the time of compilation we don't know which class should be loaded in memory but through programming we decide which class is to be loaded then we say Class.forName("Foo"); this will load Foo into memory when this line is reached during runtime. now if you want to make an instance of this at that time then you can call
now this will return an object of Class "Object" and you can typecast it to your class and then use it.. but new is used to create an object of the class when that class is already loaded in the memory. we use new for those classes which we have added in bytecode using import statement. i hope i have answered your query.. if any doubt please revert back Thanks Amit
****************************<br />In 24 hrs Earth rotates once on its Axis.
A class's byte code is loaded by the Java Virtual Machine at run time the first time an instance of that object is created using the "new" operator; but, if you want to load a class WITHOUT having to create an instance of it, Class.forName() does the trick!