Java Protocol Collection Processing

Source: Internet
Author: User

1. Handling of hashcode and equals:

1) rewrite hashcode as long as you rewrite equals;

2) If an object is to be stored with set, the two methods must be overridden.

3) If the custom object is used as a key for the map, you must override both methods.

2, ArrayList sublist can not be strong to ArrayList, return is ArrayList of the inner class sublist. It is a view of the ArrayList, and all operations are mapped to the original table.

3. Set to array using ToArray (t[] array).

4, arrays.aslist the array to the collection can not be used to modify, delete, new, because the return is an internal class of Arrays, reflecting the adapter mode.

5, comparator must meet the following conditions:

1) x, Y and y,x compare to the opposite.

2) X>y,y>z x > Z

3) X=y, then x and Z,y and Z compare the same results.

Java Protocol Collection Processing

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.