Java Reflection - Editing Array Length

前端 未结 4 1563
灰色年华
灰色年华 2020-12-21 14:10

I was wondering if it is possible to change to change the length of a class\'s integer array using the Java Reflection API. If so, how?

4条回答
  •  失恋的感觉
    2020-12-21 14:40

    I don't think it's possible to change array length even with Reflection.

    This is a reference from java tutorial.

    An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.

    http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

提交回复
热议问题