You can do it like this:

list.add(1, object1)
list.add(2, object3)
list.add(2, object2)

After you add object2 to position 2, it will move object3 to position 3.

If you want object3 to be at position3 all the time I'd suggest you use a HashMap with position as key and object as a value.

Answer from superM on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-add-an-element-at-particular-index-in-java-arraylist
How to Add an Element at Particular Index in Java ArrayList? - GeeksforGeeks
July 23, 2025 - // Adding an Element at Particular // Index in Java ArrayList import java.io.*; import java.util.ArrayList; class GFG { // Main driver method public static void main(String[] args) { // Creating an ArrayList ArrayList<String> list = new ArrayList<>(); // Adding elements to ArrayList // using add method for String ArrayList list.add("A"); list.add("B"); list.add("C"); /* Index is zero based */ // 3 gets added to the 1st position list.add(1, "D"); // 4 gets added to the 2nd(position) list.add(2, "E"); // Displaying elements in ArrayList System.out.println(list); } }
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ list-addint-index-e-element-method-in-java
List add(int index, E element) method in Java - GeeksforGeeks
December 3, 2024 - // Java code to illustrate add(int index, E elements) import java.util.*; public class ArrayListDemo { public static void main(String[] args) { // Create an empty list List<Integer> l = new ArrayList<Integer>(5); // Adding Elements in List l.add(10); l.add(20); l.add(30); // Add a new 25 at index 2 and print true // if the element is added successfully System.out.println(l.add(2, 25)); // Prints element of List for (Integer num : l) { System.out.print(num + " "); } } }
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ collections framework โ€บ java arraylist โ€บ add element(s) at specified index to arraylist in java
Add Element(s) at Specified Index to ArrayList in Java
August 7, 2023 - ArrayList<String> arraylist = new ... banana] Let us learn more in detail. The ArrayList.add() method inserts the specified element at the specified position in this list....
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ inserting an object in an arraylist at a specific position
Inserting an Object in an ArrayList at a Specific Position | Baeldung
April 3, 2025 - If we want to add an element to a specific position to an ArrayList we can use the add(int index, E element) method which is provided through the implementation of the interface of List<E>. This method let us add an element at a specific index.
๐ŸŒ
Java Code Geeks
javacodegeeks.com โ€บ home โ€บ core java
Java ArrayList Insert/Replace At Index - Java Code Geeks
January 2, 2022 - Use the ArrayList.add(int index, Object value) method to add any object or element at the specific index of ArrayList and use ArrayList.set(int index, E value) to replace the value at the specific index of ArrayList in java.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ java-list-add-addall-methods
How To Use add() and addAll() Methods for Java List | DigitalOcean
September 10, 2025 - addAll(int index, Collection<? extends E> c): Inserts all elements from the collection starting at the specified index, shifting existing elements to accommodate the new ones. Bulk operations: 2-3x faster than multiple add() calls for large datasets ยท Memory efficiency: Reduces method call overhead and potential array resizing ยท Optimized implementations: ArrayList can pre-allocate space for bulk additions ... package com.journaldev.examples; import java.util.*; import java.util.stream.Collectors; public class ListAddAllExamples { public static void main(String[] args) { // Example 1: Basic
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_arraylist_add.asp
Java ArrayList add() Method
import java.util.ArrayList; public ... an item to the list. If an index is provided then the new item will be placed at the specified index, pushing all of the following elements in the list ahead by one....
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ arraylist_add_index.htm
Java.util.ArrayList.add() Method
The java.util.ArrayList.add(int index, E elemen) method inserts the specified element E at the specified position in this list.It shifts the element currently at that position (if any) and any subsequent elements to the right (will add one to ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-do-i-insert-elements-at-a-specific-index-in-java-list
How do I insert elements at a specific index in Java list?
In the following example, we will create a list of fruits and then insert a new fruit at a specific index using the add() method. import java.util.ArrayList; import java.util.List; public class InsertAtSpecificInd{ public static void main(String[] args){ List<String> fruits = new ArrayList<>(); ...
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2013 โ€บ 12 โ€บ java-arraylist-addint-index-e-element-example
Java ArrayList add(int index, E element) example
August 21, 2014 - Simple add() method is used for adding an element at the end of the list however there is another variant of add method which is used for adding an element to the specified index. ... This method adds the element at the given index. package beginnersbook.com; import java.util.ArrayList; public ...
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2014 โ€บ 07 โ€บ java-add-element-at-specific-index-in-linkedlist-example
Java โ€“ Add element at specific index in LinkedList example
More about this method from javadoc: public void add(int index, E element): Inserts the specified element at the specified position in this list.
๐ŸŒ
Blogger
javahungry.blogspot.com โ€บ 2017 โ€บ 10 โ€บ how-to-add-element-at-specified-index-in-arraylist-example.html
How to add element at specified index in ArrayList | Java Hungry
element: It represents the value that needs to be inserted at the specified position. add(index, element) method throws IndexOutOfBoundsException if the index is out of range i.e. index < 0 or index > size() .
๐ŸŒ
Oracle
docs.oracle.com โ€บ javase โ€บ 8 โ€บ docs โ€บ api โ€บ java โ€บ util โ€บ List.html
List (Java Platform SE 8 )
April 21, 2026 - 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. The List interface places additional stipulations, beyond those specified in the Collection interface, on the contracts of the iterator, add, remove, equals, and hashCode methods. Declarations for other inherited methods are also included here for convenience. The List interface provides four methods for positional (indexed) access to list elements. Lists (like Java arrays) are zero based.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ java-list-add
Adding Elements to a List in Java: A How-To Guide
February 27, 2024 - While the basic add() method is ... method for more complex scenarios. Specifically, you can use the add() method to insert an element at a specific index in your list....
๐ŸŒ
Vultr
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ util โ€บ ArrayList โ€บ add
Java ArrayList add() - Add Element | Vultr Docs
November 29, 2024 - This example first adds "Apple" and "Banana" to the list, then inserts "Cherry" at index 1. The original "Banana" element shifts to the next index, demonstrating how elements after the insertion point are moved to accommodate the new element. ArrayList in Java automatically increases its capacity when you add elements and it reaches its current capacity.
๐ŸŒ
Educative
educative.io โ€บ home โ€บ courses โ€บ collections in java โ€บ arraylist: inserting and retrieving elements
ArrayList Insertion and Retrieval Methods in Java Lists
If we have a Collection and need to add all its elements to another ArrayList at a particular index, then the addAll(int index, Collection c) method can be used. This method inserts all of the specified collection elements into this list, starting ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-add-element-in-java-arraylist
How to Add Element in Java ArrayList? - GeeksforGeeks
July 23, 2025 - Input: list.add("A"); list.add("B"); ... // Java program to add elements // at the specified index in the list // using add(index,element) method import java.io.*; import java.util.ArrayList; class GFG { public static void main(String[] ...
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2013 โ€บ 12 โ€บ java-arraylist-addall-int-index-collection-c-method-example
Java ArrayList addAll(int index, Collection c) Method example
November 3, 2022 - Last Updated: November 3, 2022 by Chaitanya Singh | Filed Under: java ยท In the last tutorial we have shared the example of addAll(Collection c) method which is used for adding all the elements of Collection c at the end of list. Here we will see another variant add(int index, Collection c) which ...