Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of Collection FrameWork in JAVA

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "what is the use of Collection FrameWork in JAVA", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the use of Collection FrameWork in JAVA" article.

Collection is the most basic collection interface. A Collection represents a set of Object, that is, the Elements of Collection Map provides a mapping from key to value.

The difference between ArrayList and Vector, the difference between HashMap and Hashtable

A: as far as ArrayList and Vector are concerned, they are mainly from two aspects.

one。 Synchronization: Vector is thread-safe, that is, synchronous, while ArrayList is not thread-safe, not synchronous

two。 Data growth: when growth is needed, the default growth of Vector is one multiplier, while ArrayList is half of the original.

As far as HashMap and HashTable are concerned, there are mainly three aspects.

one。 Historical reasons: Hashtable is based on stale Dictionary classes, and HashMap is an implementation of the Map interface introduced by Java 1.2

two。 Synchronization: Hashtable is thread-safe, that is, synchronous, while HashMap is not thread-safe, not synchronous

three。 Value: only HashMap allows you to use null values as the key or value of an entry in a table

Storage performance and characteristics of ArrayList,Vector, LinkedList

Both ArrayList and Vector use an array to store data. The number of elements in this array is larger than the actual stored data in order to add and insert elements. They both allow elements to be indexed directly by ordinal numbers, but inserting elements involves memory operations such as array element movement, so index data is fast and data insertion is slow. Vector usually performs worse than ArrayList due to the use of synchronized method (thread safety), while LinkedList uses two-way linked lists to achieve storage. Indexing data by ordinal number requires forward or backward traversal, but when inserting data, you only need to record the front and back items of this item, so the insertion speed is faster.

8 Design 4 threads, of which two threads increase by 1 for j each time, and the other two threads decrease by 1 for j each time. Write the program.

The following program uses internal classes to implement threads without considering the order when adding or subtracting j.

Public class ThreadTest1 {

Private int j

Public static void main (String args []) {

ThreadTest1 tt=new ThreadTest1 ()

Inc inc=tt.new Inc ()

Dec dec=tt.new Dec ()

For (int iTuno Bandi)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report