I have a string with the name of a class, is there a way (writing in Java) to use that string when creating a new instance of that class, to do something like this:
object obj = new dataInString.
So the dataInString is parsed from the string.
I have a string with the name of a class, is there a way
Share
Do you mean something like
Class.forName(String)? Quoting the javadoc of the method:And then, call
Class#newInstance()on the returnedClass(it must have an empty constructor).