0

I have come across a problem with my project which I don't know how to get past. I need some way of creating a Java bean object where I can dynamically add as many variables(properties) as I want. I currently have an ArrayList of object which hold the variables: String name; boolean enabled; int id;

I need to loop through this list of Objects and add the boolean value to a single java bean object. For Example: If the ArrayList of Objects were 6, I would end up with a single object with 6 variables of the enabled boolean value. If the list grew, the number of variables will grow in the object.

Is this possible? I need this for a table where each row will get its values from the Java Bean getters, which is why all the boolean values must be in the same object.

Stefza
  • 247
  • 3
  • 18
  • 2
    You'd be better off using a `Map` – Maurice Perry Nov 19 '19 at 14:23
  • Hey check "Apache Commons / BeanUtils" or Spring BeanWrapper. In this Stackoverflow thread you can see an example of the first one. https://stackoverflow.com/questions/5856895/java-reflection-beans-property-api – Sergio Arrighi Nov 19 '19 at 14:25

0 Answers0