Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

Java ArrayList Methods

All ArrayList Methods

A list of all methods can be found in the table below.

Some methods use the type of the ArrayList’s items as a parameter or return value. This type will be referred to as T in the table.

Method 

Description

Return Type

add()

Insert an item into the list.

boolean|void

addAll()

Insert a collection of items into the list.

boolean

clear()

Clear all items from the list.

void

clone()

Make a copy of the ArrayList.

object

contains()

Check if an item is present in the list.

boolean

ensureCapacity()

Expand the list’s capacity to accommodate a specified number of items.

void

forEach()

Execute an action on each item within the list

void

get()

Retrieve the item located at a particular position within the list.

T

indexof()

Provide the index of the first occurrence of an item in the list.

int

isEmpty()

Determine if the list is devoid of any elements.

boolean

iterator()

Provide an Iterator object for the ArrayList.

Iterator

lastIndex()

Provide the index of the last occurrence of an item in the list.

int

listIterator()

Provide a ListIterator object for the ArrayList.

listIterator

remove()

Eliminate an item from the list.

boolean

removeAll()

Eliminate a set of items from the list.

boolean

removeIf()

Eliminate all items from the list that satisfy a specified condition.

boolean

replaceAll()

Substitute each item in the list with the outcome of performing an operation on that item.

void

retainAll()

Eliminate all elements from the list that are not part of a specified collection.

boolean

set()

Eliminate all elements from the list that are not part of a specified collection.

T

size()

Substitute an item at a specified position within the list.

int

sort()

Retrieve the count of items present in the list.

void

spilterator()

Provide a Spliterator object for the ArrayList.

Spliterator

subList()

Provide a sublist that grants access to a specific range of items within this list.

list

toArray()

Provide an array containing the items of the list.

object[]

trimTosize()

Adjust the capacity of the list to match the number of items, if required.

object[]