The 11th week of Java Programming Study summary 201671010130

Source: Internet
Author: User

The Nineth chapter of this week's study follows the summary of knowledge points:

Collection is a collection interface

Set Sub-interface : unordered, no repetition allowed.
List Sub-interface : ordered, can have repeating elements.

difference: Collections is a collection class

Set and List comparison:
Set: The retrieval element is inefficient, the deletion and insertion efficiency is high, and insertions and deletions do not cause the element position to change.
List: and Arrays,lists can grow dynamically, find elements efficiently, and insert deleted elements inefficiently because they cause other elements to change position.

Set and List specific subclasses:
Set
HashSet: Storing elements as a hash table, inserting deletes quickly.

List
ArrayList: Dynamic array
LinkedList: Linked list, queue, stack.

Array and java.util.Vector
Vectors are dynamic arrays .

L collection is the most basic set interface, and a collection represents a set of object, the collection element (Elements). The Java SDK does not provide classes that inherit directly from collection, and the Java SDK provides classes that inherit from collection, such as list and set.

All classes that implement the collection interface must provide two standard constructors: the parameterless constructor is used to create an empty collection, and a constructor with a collection parameter is used to create a new collection. This new collection with the incoming collectio.

L have the same elements. The latter constructor allows the user to copy a Collection.

except In addition to the list, the set interface is often used, and the elements stored in the set interface are unordered and non-repeatable, so they are called datasets;

The set interface is unordered because it does not provide a set method like List to modify elements, find, add, delete.

L HashSet class and TreeSet class

“Collection Frame"SupportSetinterface Two common implementations:HashSetand theTreeSet. In more cases, you will use theHashSetstores the collection of repeated liberties. Considering the efficiency, add toHashSetobject needs to be implemented in a way that properly distributes the hash codehashcode ()method. When you extract an element in an orderly manner from the collection,TreeSetimplementation will be useful. Add toTreeSetThe elements must be sortable.

This week's study made me feel the power of the Java language once again.

The 11th week of Java Programming Study summary 201671010130

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.