Change the design problem through "type"?

    //
    String type = "java.lang.Integer";
    //
    String val = "100";
    //
    String var = "num";
    Demo demo = new Demo ();
    demo.setKey(var);
    demo.setType(type);
    demo.setValue(val);
    
    //
    Integer num = Integer.valueOf(profileConfig.getValue());
    System.out.println(num);
    
    type ,?
Jan.21,2022

generic design can be used. Type becomes a generic type of the Demo class, and Value is a generic type directly, so you don't have to convert it when you use it.


reflection?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b4fea9-41d0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b4fea9-41d0e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?