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 are the basic knowledge of Java list application

2025-03-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what the basic knowledge about Java list application is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

I. addition and deletion of array column data:

List list = new LinkedList ()

List = new ArrayList ()

Generates an array column object and creates a two-way join table.

Join tables are divided into one-way join tables and two-way join tables; one-way join tables are like: a can only go to b, b, not c; two-way join tables are like: a can go to b, b can also go to a

The purpose of a two-way concatenated table is that you can insert data anywhere in a sequence.

List.add (0, "b")

Add data to the array column, 0 for the subscript in the array, and "b" for the added data.

After establishing a two-way join table, you can insert data anywhere in the sequence with a change of 0.

For example, insert data list.add (list.size (), "any") in the array column

B = list.remove ("b")

B = list.remove (0)

Delete the data in the series, you can use the above two methods to delete. One is to find a partner, and the other is to find a subscript.

2. Java list sorting:

String [] strArray = new String [] {"z", "a", "C"}

List list = Arrays.asList (strArray)

An array column object and is the same size as strArray.

Collections.sort (list)

Sort in ascending order of ASCII.

Collections.sort (list, String.CASE_INSENSITIVE_ORDER)

Sort in English alphabetical order, ignoring case.

Collections.sort (list, Collections.reverseOrder ())

Sort by descending order of ASCII.

Collections.sort (list, String.CASE_INSENSITIVE_ORDER)

Collections.reverse (list)

Sort first in English alphabetical order, and then sort in descending order.

3. Operation of list:

List1.retainAll (list2)

Keep only the same parts of list1 and list2 (intersection)?

List1.subList (newSize, list1.size ()). Clear ()

Returns the section between newSize and list1.size.

Method summary:

List.add (): add data

List.remove (): delete data

Arrays.asList (): column of specified size

Collections.sort (): sort by ASCII ascending order

Collections.reverseOrder () and Collections.reverse (): sort by ASCII descending order, the difference lies in the parameters

List.addAll (): add () all data

List.removeAll (): delete () all data

List.retainAll (): preserve intersection

List.subList (size1, size2): returns data from size1 to size2

What is the basic knowledge of Java list application shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Development

Wechat

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

12
Report