Dark Horse programmer-array reflection

Source: Internet
Author: User

--------------------- Android training, Java training, and hope to communicate with you! ---------------------- 1. for arrays, arrays of the same element type and dimension belong to the same class (same bytecode), for example, int [] a1 = new int [] {, 3 }; int [] a2 = new int [] {1, 2, 3, 4, 5}; string a3 = new string [] {"22", "33 "}; a1 and A2 belong to the same classa1 and A3, not the same class. 2. assign values between arrays to object obj1 [] = A1; // The error object obj2 [] = A3; // Why Is this correct? Originally, the value assignment of array objects is the assignment of corresponding elements respectively. After Statement 2 is executed, there are two object-type objects in obj2. If Statement 1 assigns values in this mode, it assigns three int-type values to the object. However, the native data type is not a subclass of the object and therefore cannot be assigned a value, so it is wrong (the package class is not automatically packed here and then assigned a value ). 3. all arrays are subclasses of objects. Object OBJ = A1; // 4 is acceptable. quickly print out an Array Using arrays. aslist (A1); convert the array to list and print it directly. Note: The receiving parameter is a variable parameter. When an array of non-native data type is input, it is automatically split into list elements; when the input is an array of native data type (such as int []), it will not be automatically split and will only be used as an element in the list, that is, the array itself. -------------------- Android training, Java training, and hope to communicate with you! ---------------------- For details, please refer to: http://edu.csdn.net/heima

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.