I have an array with field names - fieldNamesArr and array with values for those fields - fieldValuesArr. Also I have Object obj,created form class Class using .newInstanse();.
How can I set appropriate fields in obj using this two arrays?
(we're assuming that obj has all of this fields and they are public)
Class ourClass = Definer.getClassByName(tmpStrArr[1]);
obj = ourClass.newInstance();
List<String> fieldNamesArr = new ArrayList<>();
List<String> fieldValuesArr = new ArrayList<>();
[remark 1] Supposed that obj doesn't have a complex fields (just primitive types)
Aucun commentaire:
Enregistrer un commentaire