Order of Fields returned by Class.getFields()

后端 未结 4 1165
后悔当初
后悔当初 2021-02-19 07:06

Javadoc for Class.getFields() say: \"The elements in the array returned are not sorted and are not in any particular order.\"

Any hints on how the order act

4条回答
  •  花落未央
    2021-02-19 07:50

    Create a helper method that returns a sorted list, and use that instead whenever you need the list of fields. Or lookup by name instead of index.

提交回复
热议问题