What is the ArrayList.contains() method in Java?
The ArrayList.contains() method in Java is used to check whether or not a list contains a specific element.
To check if an element is in an array, we first need to convert the array into an ArrayList using the asList() method and then apply the same contains() method to it.
Syntax
This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.
Code
The following code snippet demonstrates how the contains() method is used to check the presence of an object in a list:
This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.
To apply the contains() method to an array, we first need to convert the array into an ArrayList:
This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved