Java Reflection, Ignore case when using GetDeclaredField

前端 未结 7 669
不思量自难忘°
不思量自难忘° 2021-01-18 05:08

Let\'s say I have a class with a string field named \"myfield\", and use reflection to get the field, I\'ve found that Object.getClass().getDeclaredField(\"myfield\");

7条回答
  •  伪装坚强ぢ
    2021-01-18 05:53

    The only way I see is to iterate over all declared fields and compare the names case-insensitively to the field name you are looking for.

提交回复
热议问题