mercredi 13 juillet 2022

Use reflection to get entries from a list

I have a LinkedList of Strings

List<String> list = new LinkedList();
list.add("");

Using Reflection, how would I be able to get the Field object of list.get(0) and then set the field object with a value such as "Hello"?

Something like this:

Field field = //the field entry of list.get(0)
field.set() // set field with a string "Hello"




Aucun commentaire:

Enregistrer un commentaire