search
HomeJavaJavagetting StartedWhat are the main implementation classes of list collections?

What are the main implementation classes of list collections?

Jun 17, 2020 pm 02:35 PM
listImplementation classgather

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function