Inserting, Replacing, and Removing ArrayList Elements

The playlist
A music app keeps a playlist in an ArrayList, in the order the songs will play.
ArrayList<String> songs = new ArrayList<String>();
songs.add("Intro");
songs.add("Rain");
songs.add("Static");
songs.add("Neon");
songs.add("Echo");
The calls below run one after another, so each one starts from the list the one before it left. The table after the three calls shows every state.
Inserting at an index
songs.add(2, "Bridge");
This version of add puts "Bridge" at index 2. The elements that were at index 2 and above each shift one place to the right. So "Static" goes from index 2 to 3, "Neon" from 3 to 4, and "Echo" from 4 to 5. The size goes from 5 to 6, and nothing is lost.
Replacing an element
String old = songs.set(0, "Opening");
The call stores "Opening" at index 0 and returns the element that was there, so old is "Intro". No element changes its index, and the size stays 6.
Removing an element
String gone = songs.remove(3);
Before the insertion, index 3 held "Neon". The insertion shifted "Static" there, so this call removes "Static" and gone refers to it. The elements after index 3 each shift one place to the left, so "Neon" goes back to index 3 and "Echo" to index 4. The size drops to 5.
After012345
the five appendsIntroRainStaticNeonEcho
add(2, "Bridge")IntroRainBridgeStaticNeonEcho
set(0, "Opening")OpeningRainBridgeStaticNeonEcho
remove(3)OpeningRainBridgeNeonEcho
Valid indexes
The methods get, set, and remove name an element that already exists, so their index must be from 0 through size() - 1. The two-argument add names the place a new element will go. So it also accepts size() itself, which puts the new element last. Any index outside the allowed range throws an IndexOutOfBoundsException.