Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the List interface

Shulou Source: shulou.com Published: 2022-06-03 06:12:10 09月15日 Update

The main content of this article is to explain "what is the List interface", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the List interface"?

List interface

List is a subinterface of Collection, and its most important feature is that it allows the storage of duplicate element data. The definition of this interface is as follows:

Public interface List extends Collection

But what needs to be clear is that the list subinterface extends the method of the Collection interface.

No. Method name type description 01public E get (int index) General get data on the specified index 02public E set (int index, E element) ordinary modification specified index data 03public ListIterator listIterator () ordinary return ListIterator interface object

But List itself still belongs to an interface, so if you want to use an interface, you must use subclasses to complete the definition. There are three common subclasses in the list subinterface: ArrayList, Vector, and LinkedList.

List subinterface

Starting from JDK1.9, some static methods are appended to the List interface to facilitate user processing.

Example: static method of observing List

Import java.util.Arrays;import java.util.List;public class JavaAPIDemo {public static void main (String [] args) throws Exception {List all = List.of ("Hello", "World", "Hello", "MLDN", "ele.me?") ; Object result [] = all.toArray (); for (Object temp: result) {System.out.println (temp + ","); / / [Hello, World, Hello, MLDN, ele.me?] At this point, I believe you have a deeper understanding of "what is the List interface". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Interface method normal data Hello content subclass Index Learning practical Deep maximum clear three element interest name practicality actual object Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information Xiaomi NVidia Shulou Technology