Java Reflection to set attributes

后端 未结 3 726
遇见更好的自我
遇见更好的自我 2020-12-21 08:19

I have a class that has many settable/gettable attributes. I\'d like to use reflection to set these attributes, but I have 2 questions about my implementati

3条回答
  •  春和景丽
    2020-12-21 08:38

    Using setter methods is the accepted way to set values for class member variables, reflection should definitely not be used for that as the code will be harder to understand and run much more slowly.

    Most IDEs (eg Eclipse or NetBeans) include tools for automatically creating getter and setter methods for a class's fields.

提交回复
热议问题