Java ArrayList
Java ArrayList is a resizable array in which you can store similar type of objects. We can add to or remove objects of ArrayList dynamically, because ArrayList is resizable.
In this tutorial, we will learn about the constructors and methods of ArrayList class, and some of the how-to scenarios involving ArrayList.
Java ArrayList Methods
Java ArrayList class provides methods which we can call on an ArrayList instance. Following are the list of functions and links to their respective tutorials with examples.
- Java ArrayList – add()
- Java ArrayList – addAll()
- Java ArrayList – clear()
- Java ArrayList – clone()
- Java ArrayList – contains()
- Java ArrayList – ensureCapacity()
- Java ArrayList – forEach()
- Java ArrayList – get()
- Java ArrayList – indexOf()
- Java ArrayList – isEmpty()
- Java ArrayList – iterator()
- Java ArrayList – lastIndexOf()
- Java ArrayList – listIterator()
- Java ArrayList – remove()
- Java ArrayList – removeAll()
- Java ArrayList – removeIf()
- Java ArrayList – removeRange()
- Java ArrayList – retainAll()
- Java ArrayList – set()
- Java ArrayList – size()
- Java ArrayList – spliterator()
- Java ArrayList – subList()
- Java ArrayList – toArray()
- Java ArrayList – trimToSize()
Java ArrayList How-Tos
Following tutorials covers some of the how-to scenarios with an ArrayList in Java.
- How to create an empty ArrayList? – This tutorial contains examples to create an empty ArrayList in Java.
- How to create an ArrayList of specific size? – This tutorial contains examples to create an ArrayList with specified initial capacity.
- How to initialize an ArrayList? – This tutorial contains examples to initialize an ArrayList with elements
- How to iterate over elements of ArrayList? – This tutorial covers different processes available in Java, to iterate over elements of an ArrayList.
- How to reverse an ArrayList? – This tutorial explains how you can reverse the order of elements in an ArrayList.
- How to delete all elements from an ArrayList?
- How to delete element at specific index in ArrayList?
- How to add all the elements of one ArrayList to another ArrayList?
- How to add elements to ArrayList in Java?
- How to check if an ArrayList is empty?
- How to check if ArrayList contains a specific object/element?
- How to get element from ArrayList at specific index?
- How to print all elements of an ArrayList?
- How to remove elements from ArrayList based on condition?
- How to remove elements from ArrayList in specific index range? – This tutorial covers examples to remove elements of an ArrayList that are present in a given specific index range.
- How to insert element in ArrayList at specific position?
- How to update an element of ArrayList?
Conclusion
In this Java Tutorial, we learned the syntax and usage of constructors and methods of Java ArrayList and also common different scenarios where ArrayList could be involved.