In this section you will learn how to know that whether any class consists No-Argument Constructor or not ?. Here is an example that provides the usage of the newInstance() method in more detail.
Here in our example we have used "forName()" static method of Class and then we have invoked newInstance() method to create a new object without any argument. Invoking newInstance() method throws a NoSuchMethodException if the class does not have any no-argument constructor.
Here is code for example:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: September 10, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles