I'm getting data from a DB and access through the field names of the class DBUserValues and want to save the results in a DBUserValues object. There is always only one result. How to I access these static variables with a string? Is there a better way to do this?
public class DBUserValues {
public static String username;
public static String firstname;
}
Go through results and save them
for (Field field : user.getClass().getDeclaredFields()) {
// Result should get saved in DBUserValues object
// DBUserValues.username = result.getString(field.getName();
// DBUserValues.(field.getName()) = result.getString(field.getName());
}
Aucun commentaire:
Enregistrer un commentaire