Back to ArrayList

Lesson PreviewLesson 5 of 7 in this unit

7.5 Searching

Part of ArrayList in AP® Computer Science A. Read the opening section, then create a free account for the full interactive lesson, practice, and progress tracking.

Now that you know about algorithms in Java, let's take a look at a common problem which algorithms are made to solve: searching. Imagine you are the host of a large party and have hundreds of guests with their names stored in an ArrayList. When the time comes, people start arriving at your door and you stand outside to check them in one-by-one. To do this you utilize an algorithm known as Linear Search. A Linear Search algorithm is used when you need to find a specific element in an ArrayList. It goes through each element in the list (iterating) until the specific element you are looking for is found.

Continue the full lesson in Stellar

Create a free account to unlock the remaining sections, checkpoints, course practice, and progress tracking for AP® Computer Science A.