Inserting, Deleting, and Rearranging ArrayList Elements

Two parallel lists
A reading club keeps its list in two collections. ArrayList<String> books holds the titles, and ArrayList<Integer> pages holds each book's length at the same index.
books: "Kindred", "Holes", "Beloved"
pages: 264, 233, 324
Nothing in Java ties the two lists together. They stay parallel only as long as every change to one is made to the other at the same index.
Inserting and deleting
The club adds a book as the second one to read.
books.add(1, "Matilda");
pages.add(1, 240);
Both calls put the new element at index 1 and shift the elements after it up by one. So each title still has its own page count beside it. Deleting works the same way: books.remove(2) and pages.remove(2) take out "Holes" and its 233 together. Removing from only one list would pair every later title with the wrong length.
Shifting and rotating
The call books.remove(0) on its own shifts each remaining title one index toward the front, and the list gets shorter. A shift that has to keep the size adds a placeholder at the end afterward.
Since remove returns what it took out, the removed element can be put back somewhere else instead, which turns the shift into a rotation. Appending it at the end rotates the list to the left. The statement books.add(0, books.remove(books.size() - 1)); would rotate it to the right, making the last book the first. The club makes none of these changes, so its list stays "Kindred", "Matilda", "Beloved".
Reversing
A reversal trades the two end titles, then the two just inside them, until it reaches the middle, reading with get and writing with set.
int last = books.size() - 1;
for (int i = 0; i < books.size() / 2; i++)
{
String held = books.get(i);
books.set(i, books.get(last - i));
books.set(last - i, held);
}
Three books give books.size() / 2 equal to 1, so the loop runs once, and it swaps "Kindred" with "Beloved". "Matilda" stays in the middle. The size never changes, since set replaces elements and adds none. The same loop, with pages in place of books and Integer in place of String, reverses the page counts so the two lists stay parallel.
Traversing three collections
A member records the pages read so far in an int array, at the same indexes as books and pages. One index walks all three.
int[] read = {324, 90, 264};
for (int i = 0; i < books.size(); i++)
{
int left = pages.get(i) - read[i];
System.out.println(books.get(i) + ": " + left);
}
After the reversal, pages holds 324, 240, and 264. The loop prints Beloved: 0, Matilda: 150, and Kindred: 0. The array is read with read[i], and the lists with get(i).
The bound books.size() works because read has an entry for every book. An array with fewer entries than the lists would need its own length in the loop condition too.