What are the main implementation classes of list collections?

王林
Release: 2020-06-17 14:35:57
Original
12243 people have browsed it

What are the main implementation classes of list collections?

The main implementation classes of list collection are:

1. ArrayList collection

Implementation of variable-size array of List interface . (Queries are fast, additions and deletions are slow.) This implementation is not synchronous (multi-threading issue).

2. LinkedList collection

The linked list implementation of the List interface. This implementation is not synchronous.

java.util.LinkedList collection implements List interface.

Features:

(1) The bottom layer is a linked list structure: slow to query, fast to add and delete.

(2) contains a large number of methods for operating the first and last elements.

(Video tutorial recommendation:java video tutorial)

Note: Use the unique method of LinkedList collection, and you cannot use polymorphism.

—public void addFirst(E e): Insert the specified element into the beginning of this list.

—public void addLast(E e): Add the specified element to the end of this list.

—public E getFirst(): Returns the first element of this list.

—public E getLast(): Returns the last element of this list.

—public E removeFirst(): Remove and return the first element of this list.

—public E removeLast(): Removes and returns the last element of this list.

—public E pop(): Pop an element from the stack represented by this list. Equivalent to removeFirst().

—public void push(E e): Push the element into the stack represented by this list. Equivalent to addFirst(E e).

—public boolean isEmpty(): Returns true if the list does not contain elements.

—clear(); //Clear the elements in the collection, and then get the elements in the collection will throw NoSuchElementException.

3. Vector collection

can realize a growable object array. This implementation is synchronous. The earliest collection of JDK1.0 has an array at the bottom, but it is single-threaded and relatively slow.

Recommended tutorial:java entry program

The above is the detailed content of What are the main implementation classes of list collections?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!