JAVA Reflection Learning Notes 2__java

Source: Internet
Author: User

-----------Android Training, Java training, Java Learning Technology blog, look forward to communicating with you. ------------

I. Reflection of an array:

A the array with the same dimension and element type belongs to the same type, which has the same class instance object.

b the Getsuperclass () method that represents the class instance object of an array returns the class that corresponds to the object class.

c The one-dimensional array of basic types can be used as object type, not as a object[] type, a one-dimensional array of primitive types that can be used as object types and can be used as object[] types

Two. Comparison and hashcode analysis of Arraylist-hashset:

(a) Overrides of equals () and Hashcode () methods

b When an object is stored in the HashSet collection, it is not possible to modify those fields in the object that participate in the computed hash, otherwise the modified hash value of the object is different from the hash value originally stored in the HashSet collection, in which case Even if the Contains method retrieves an object in HashSet using the argument used by the current reference of the object, the result of the object cannot be found, which also results in a memory leak because the current object cannot be deleted individually from the HashSet collection.

Three. The role of reflection: the realization of the framework function

(a) core issues to be addressed in the framework and framework

I do the house to sell to the user to live, by the user to install doors and windows and air-conditioning, I do the house is the framework, users need to use my frame, the door and window into the framework I provided, the framework and tool classes are different, the tool class is called by the user's class, and the framework is to invoke the user-provided class

(b) Core issues to be addressed by the framework

I. I write the framework how to call to the user after the class written

                       ii.               because it is not possible to know the class to be invoked when writing a program, it is not possible to directly new an instance object of a class, but to do so with reflection.

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.