I want to create a java class with dynamic number of variables. Those dynamic variables will be read from a config file.
Example: I have a properties file like,
{
"data": "int",
"name": "string",
"addr": "string",
"age" : "int"
}
In some cases, new variables can be there or few variables are missing from above config.
I want to create a java with variables mentioned in above properties file. Is it possible in java to create such class and if yes then can someone provide sample code for that?
MapMaporPropertiesis the way to go. If there is a pattern in them, you may consider subclasses: each subclass can add any number of variables to those inherited from the superclass. It’s not really dynamic, though.