Home » Java programs » Java ArrayList programs

Java program to search an element from an ArrayList

In this java program, we are going to learn how to search an element from an ArrayList? To find an element, we use contains() method of ArrayList class.
Submitted by IncludeHelp, on October 21, 2017

Given an ArrayList, and we have to find/search an element from the list using Java program.


Method is used to check whether an element is exists in the ArrayList or not, this method return "false" if element is not found, and returns "true" if element exists in the ArrayList.


boolean ArrayList.contains(element);

Consider the program

import java.util.ArrayList;

public class SearchAnElement {

	public static void main(String[] args) {
		//ArrayList object 
		ArrayList arrList = new ArrayList();

		//adding elements in the list

		//searching element "300"
		boolean isFound = arrList.contains("300");
		if(isFound == false)
			System.out.println("Element is not found in the list");
			System.out.println("Element is found in the list");



Element is found in the list

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.