java - Checking if an object is an instance of a specific datatype given by a user -
i struggling checking if object instance of specific datatype, given user input. example:
object = new object(); string userdatatype = joptionpane.showinputdialog("what kind of datatype want check?"); if(object instanceof userdatatype)) dostuff();
i tried reflections still don't manage behind this...
thank in advance!
try comparing getsimplename()
of class of object, returns unqualified class name (without bundle name).
object o; string userinput; if (o.getclass().getsimplename().equalsignorecase(userinput))
java class types
No comments:
Post a Comment