what's thew benefits of dynamic loading in java?
and How can I load a classes befopre run the program?

what's thew benefits of dynamic loading in java?

DI frameworks like Spring are based around the concept of dynamically loading classes on fly and creating objects (aka beans) using them on demand or lazily. A servlet implementation like Tomcat picks up user defined class name from the web.xml file and loads the corresponding class from the packaged WAR file etc. etc.

and How can I load a classes befopre run the program?

If you have hard-references to a given class, it would automatically be loaded by the classloader. Otherwise, you can use the method Class.forName("pkg.Klass") to load a class on fly which returns the loaded Class object for that given class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.