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
๐ŸŒ
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 ArrayList<>(); arraylist.add("apple"); // [apple] arraylist.add("banana"); // [apple, banana] //Adding a new element at index position 1 arraylist.add(1, "grapes"); // [apple, grapes, banana] //Adding multiple elements element at index position 0 arraylist.add(0, Arrays.asList("date", "guava")); // [date, guava, apple, grapes, banana]
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ arraylist_add_index.htm
Java.util.ArrayList.add() Method
public void add(int index, E element) index โˆ’ The index at which the specified element is to be inserted. element โˆ’ The element to be inserted. This method does not return any value.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-util-arraylist-add-method-java
Java ArrayList add() Method with Examples - GeeksforGeeks
March 14, 2026 - Return Type: boolean: It returns true, if the element was successfully added. ... This method inserts the specified element at a given position in the ArrayList. It shifts the current element at that position and subsequent elements to the right.
๐ŸŒ
W3Resource
w3resource.com โ€บ java-tutorial โ€บ arraylist โ€บ arraylist_add-element-index.php
Java add method to append an element to a ArrayList at a specified position - w3resource - w3resource
Java ArrayList.add(int index, E element) Method with example: This method is used to insert an element to the ArrayList object at a specified index.
Find elsewhere
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2013 โ€บ 12 โ€บ java-arraylist-addint-index-e-element-example
Java ArrayList add(int index, E element) example
August 21, 2014 - This method adds the element at the given index. package beginnersbook.com; import java.util.ArrayList; public class AddMethodExample { public static void main(String[] args) { // ArrayList of String type ArrayList<String> al = new ArrayList<String>(); // simple add() methods for adding elements at the end al.add("Hi"); al.add("hello"); al.add("String"); al.add("Test"); //adding element to the 4th position //4th position = 3 index as index starts with 0 al.add(3,"Howdy"); System.out.println("Elements after adding string Howdy:"+ al); //adding string to 1st position al.add(0, "Bye"); //Print System.out.println("Elements after adding string bye:"+ al); } }
๐ŸŒ
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
In the below example, we have created an ArrayList of type Integer and added elements to it by using add(element) method. After that, we are adding two elements 36 and 48 at the 3rd index and 0th index respectively by using the add(index, element) method. import java.util.*; public class ...
๐ŸŒ
LabEx
labex.io โ€บ questions โ€บ how-does-the-add-method-in-arraylists-handle-insertion-at-840441
How does the 'add' method in ArrayLists handle insertion at a specific index? | LabEx
September 17, 2025 - In Java, the `add(int index, E element)` method of the `ArrayList` class allows you to insert an element at a specific index.
๐ŸŒ
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 ...
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ library โ€บ arraylist โ€บ add
Java ArrayList add()
The ArrayList add() method can take two parameters: index (optional) - index at which the element is inserted ยท element - element to be inserted ยท If the index parameter is not passed, the element is appended to the end of the arraylist. returns true if the element is successfully inserted ...
๐ŸŒ
LabEx
labex.io โ€บ labs โ€บ java-adding-elements-to-arraylists-at-specific-index-109942
Adding Elements to ArrayLists at Specific Index | LabEx
Learn how to add elements to an ArrayList at a specific index in this programming tutorial. Enhance your coding skills and create engaging applications.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_arraylist_add.asp
Java ArrayList add() Method
If an index is not provided then the new item will be placed at the end of the list. ... T refers to the data type of items in the list. ... import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); cars.add(2, "Toyota"); System.out.println(cars); } }
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-insert-an-object-in-an-arraylist-at-a-specific-position-in-java
How to insert an object in an ArrayList at a specific position in java?
The add() method of the ArrayList class helps you to add elements to an array list. It has two variants โˆ’ Therefore using the add() method that accepts index value, you can add elements to the list at the required position.
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ collections framework โ€บ java arraylist โ€บ java arraylist add() โ€“ add a single element to list
Java ArrayList add() - Add a Single Element to List
August 7, 2023 - The ArrayList.add() in Java adds a single element to the list, either at the end of the list or at the specified index position. Always use generics for compile-time type safety while adding the element to the arraylist.
๐ŸŒ
Javatpoint
javatpoint.com โ€บ java-arraylist-add-method
Java ArrayList add() method with Examples - Javatpoint
Java ArrayList add() method with Examples on add(), addAll(), clear(), clone(), contains(), ensureCapacity(), get(), indexOf(), isEmpty(), iterator(), lastIndexOf(), listIterator(), remove(), removeAll(), subList(), toArray(), trimToSize() etc.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ add-an-element-to-specified-index-of-arraylist-in-java
Add an element to specified index of ArrayList in Java
July 30, 2019 - An element can be added to the specified index of an ArrayList by using the java.util.ArrayList.add() method. This method has two parameters i.e. the specific index at which to insert the element in the ArrayList and the element itself. If there i