Dark Horse programmer-java Base-array of reflections

Source: Internet
Author: User

An array is an object that has the same byte code (the same type) as an array with the same number of dimensions and element types.

All arrays whose parent class are object. Object o = new Int[2] or object o = new int[2][2]; a one-dimensional array of basic types can be used as an Object type, not as a object[] type; int[] arr = new in    T[2]; Object O1 = Arr object[] O2 = arr//Will error object[] O3 = new object[2][2]; Yes, because the two-dimensional base array, which contains an array, and a one-dimensional array is Object.  So you can use non-primitive types of one-dimensional arrays, either as object types or as object[] types. Reflection on an array, which is the reflection generationint[] irr= int[].class.newinstance ();System.out.println (irr.length);the above method is wrong. You can get the class object of an array through Int[].class, but you cannot know the concrete constructor of the array when you newinstance (), so you cannot create an array like this    Create an arrayarray.newinstance (class<?> type,int length)

Dark Horse programmer-java Base-array of reflections

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.