Java Basics (vi)---list

Source: Internet
Author: User

LIST

(1) List is a sub-interface of collection
Features: Orderly (the storage sequence and the order of removal), repeatable.

(2) Unique traversal capabilities of the list collection
A: Combined by size () and get ().

Example:

for (int x=0; x<list.size (); x + +) {
String s = list.get (x);
System.out.println (s);
}

(3) The unique function of the list iterator; (listiterator)
It can be traversed in reverse, but it must be traversed first and seldom used.

Sub-class features of list
ArrayList
The underlying data structure is an array , query fast, and delete slowly.
Threads are unsafe and highly efficient.
Vector
The underlying data structure is an array , query fast, and delete slowly.
Thread-safe, low-efficiency.
LinkedList
The underlying data structure is linked list , query slow, delete quickly.
Threads are unsafe and highly efficient.

ArrayList and vectors

The ArrayList and vector classes encapsulate a dynamic object[] array that allows redistribution. The ArrayList and Vector objects use the initialcapacity parameter to set the length of the array, and their initialcapacity automatically increases when the elements added are beyond the length of the array to be changed.

LinkedList

A: Has a unique function
A: Add
AddFirst ()
AddLast ()
B: Delete
Removefirst ()
Removelast ()
C: Get
GetFirst ()
GetLast ()

Common data structures

A: Stack advanced back out
B: Queue FIFO
C: Array query fast, adding and deleting slow
D: List query slow, and delete fast

Java Basics (vi)---list

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.