| |

VerySource

 Forgot password?
 Register
Search
View: 629|Reply: 1

Differences and connections between the four classes in java.util

[Copy link]

3

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-15 21:30:01
| Show all posts |Read mode
Talk about some connections and differences between the ArrayList, LinkdList, HashMap, and Vector classes in the collection class?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-17 18:30:01
| Show all posts
Both ArrayList and LinkdList are implementations of the List interface. LinkdList uses a linked list data structure. ArrayList represents an array of variable size. Vector is also an implementation of the List interface. Its function is similar to ArrayList. The difference is that the Vector class implementation uses a synchronization mechanism, and ArrayList does not use a synchronization mechanism.

    ArrayList allows fast random access, but when adding and removing elements in the center of the List, the efficiency is very poor.
    LinkedList provides the best sequential access, which can improve the efficiency of adding and removing elements in the central position of List. LinkedList also does not use a synchronization mechanism.

HashMap is the implementation class of Map, which accesses the key according to the hash algorithm, and has good access performance. At the same time, HashMap allows null to be the key or value of the map.

I copied it from the book.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list