A collection of basic Java knowledge

Source: Internet
Author: User

Collection Collection

Features: variable length, only reference types can be stored, and different types of elements may be stored

List

  Features: The elements are ordered (in the same order as they are stored and taken out) and can be repeated

    • LinkedList

Data structure: The underlying data structure is an array, query fast, and delete slowly. Thread insecure, high efficiency

    • ArrayList

Data structure: The underlying data structure is linked list, query slow, delete quickly. Thread insecure, high efficiency

    • Vector

Data structure: The underlying data structure is an array, query fast, and delete slowly.  Thread-safe, low-efficiency.  

Set

  Features: element unordered, unique

    • HashSet 

data structure: the underlying data structure is a hash table. The bottom of the hash table relies on two methods: Hashcode () and Equals ().
Order of judgment when storing data:
1. First determine if the object's Hashcode () is the same.
2. Yes: Continue with equals () to see if its return value is
True: The description element is duplicated and not added.
False: It is added directly to the collection.
No: It is added directly to the collection.

when you see the collection of hash structures, we may need to rewrite hashcode () and Equals (). and we don't have to write it ourselves, and we can generate it automatically.

    • TreeSet

A collection of basic Java knowledge

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.