ArrayList Methods

Sophie Anderson
6 min read
Listen to this study note
Study Guide Overview
This study guide covers ArrayList methods in Java. It explains adding elements to the beginning, middle, and end of an ArrayList. It also discusses accessing, removing, and modifying elements. The guide uses examples to demonstrate size(), get(), add(), remove(), and set() methods, emphasizing zero-indexing and index shifting.
Note: This will use arrayOne from Topic 6.1, which is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
In this course, there are a few methods from the ArrayList class that you are expected to know and use for the following four topics. We will be talking about them and their functionalities below.
#Adding Elements to the End Of an ArrayList
After we call the ArrayList constructor, we have an empty ArrayList. After that, we need to add elements to this ArrayList! How? We use the following method:
- boolean add(E obj) This has a boolean return because this method returns true to show that the element has been successfully added.
Let's try to recreate arrayOne from the Unit 6 Guide and make it into an ArrayList!
import java.util.ArrayList;
ArrayList
Oh no! It seems that the author of this guide got distracted while reading other Fiveable articles and added too many 5's and forgot to add 1 and 2. Perhaps he was obsessed with getting 5s and did not want to fail hi...

How are we doing?
Give us your feedback and let us know how we can improve