What is the purpose of java.lang.reflect.Array's getter and setter methods?

前端 未结 3 1626
执笔经年
执笔经年 2021-02-09 18:03

Java Class java.lang.reflect.Array provides a set of tools for creating an array dynamically. However in addition to that it has a whole set of methods for accessing (get, set,

3条回答
  •  迷失自我
    2021-02-09 18:45

    These methods relieve you from the burden of checking and casting the array yourself, if all you know is "that object is an array of some (possibly primitive) type".

    I myself have seen uses of this only in frameworks and utilities, like commons-beanutils. This framework reflectively accesses properties of java beans, and uses the Array methods to access elements of array properties.

提交回复
热议问题