search
HomeJavaJavaBaseWhat are the common methods of list collection in Java?

What are the common methods of list collection in Java?

Nov 18, 2019 pm 02:00 PM
javalistCommon methodsgather

What are the common methods of list collection in Java?

The List interface inherits the Collection interface, so some methods in the Collection collection are also inherited by the List collection.

Common methods for List collections:

1. void add(int index, E element)

Insert at the specified position element, and all subsequent elements are moved back one element.

What are the common methods of list collection in Java?

2、boolean addAll(int index, Collection extends E> c)

Insert c in the specified position Collection of all elements, if the collection changes, returns true, otherwise returns false.

It means that when the inserted set c has no elements, then false is returned. If the set c has elements and the insertion is successful, then true is returned.

What are the common methods of list collection in Java?

3. E get(int index)

Returns the element at the specified index position in the list collection.

What are the common methods of list collection in Java?

4. int indexOf(Object o)

Returns the index position of the first occurrence of o object in the list collection, if There is no o object in the list collection, then -1

What are the common methods of list collection in Java?

5, E remove(int index)

Delete the specified index Object

What are the common methods of list collection in Java?

6、E set(int index, E element)

The element at the index position is changed to element Element

What are the common methods of list collection in Java?

7、List subList(int fromIndex, int toIndex)

Returns the element from index fromIndex to toIndex Collection, including left but not right

What are the common methods of list collection in Java?

Recommended tutorial: Java tutorial

The above is the detailed content of What are the common methods of list collection in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor