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 uses of Java super interface List

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "what is the usage of Java super interface List". In daily operation, I believe many people have doubts about the usage of Java super interface List. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what is the use of Java super interface List?" Next, please follow the editor to study!

List is one of the three direct sub-interfaces of Collection, in which the data can be retrieved through the location, and the user can insert the data at the specified location. The data for List can be empty and can be repeated. The following are the comments on the documentation. Just look at the first two paragraphs:

An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.

Unlike sets, lists typically allow duplicate elements. More formally, lists typically allow pairs of elements E1 and e2 such that e1.equals (E2), and they typically allow multiple null elements if they allow null elements at all. It is not inconceivable that someone might wish to implement a list that prohibits duplicates, by throwing runtime exceptions when the user attempts to insert them, but we expect this usage to be rare.

List-specific method

We focus on the approach that is different from Collection, mainly as follows:

/ / inserts the specified collection into the current collection boolean addAll (int index, Collection) o. ListIterator (); while (e1.hasNext () & & e2.hasNext ()) {Eo1 = e1.next (); Object O2 = e2.next (); / / the equals method if (! (o1==null?) of the data element is used here. O2==null: o1.equals (O2)) return false;} return! (e1.hasNext () | | e2.hasNext ());} public int hashCode () {int hashCode = 1; for (E: this) / / the hashCode method hashCode = 31*hashCode + (e==null? 0: e.hashCode ()) of the data element is used here; return hashCode } at this point, the study on "what is the use of the Java super interface List" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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