I want to pass a class as an argument to a function. But I have the string variable which contains name of that class.
This is the general method, you'll need to use a fully qualified class name.
myInstance.myMethod (Class.forName("fully.qualified.ClassName"));
Use static method of Class class
yourMethod(other arguments,..., Class.forName("name of your class in string Formate.."));
this method return a Class class object for your class...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With