A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/arraydeque/java_arraydeque_contains.php below:

Website Navigation


Java ArrayDeque Class: contains() Method

Java ArrayDeque Class: contains() MethodLast update on August 19 2022 21:51:24 (UTC/GMT +8 hours) public boolean contains(Object o)

The contains() method is used to check if a given deque contains an specified element or not.

More formally, returns true if and only if this deque contains at least one element e such that o.equals(e).

Package: java.util

Java Platform: Java SE 8

Syntax:

contains(Object o)

Parameters:

Name Description o object to be checked for containment in this deque

Return Value:

true if this deque contains the specified element

Return Value Type: boolean

Pictorial Presentation

Example: Java ArrayDeque Class: contains() Method

import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
   public static void main(String[] args) {
    // ArrayList with Capacity 4
      ArrayDeque<String> StudentList = new ArrayDeque<String>(4);
      //Added 4 elements
       StudentList.add("David");
       StudentList.add("Tom");
       StudentList.add("Rohit");
       StudentList.add("Paul");
      
       System.out.println("Students in the list are : ");
       System.out.println(StudentList);
  
       System.out.print("Is list contains the student Tom?");
       System.out.println(StudentList.contains("Tom"));
       System.out.print("Is list contains the student Sudhir?");
       System.out.println(StudentList.contains("Sudhir"));
   }
}
 

Output:

Students in the list are : 
[David, Tom, Rohit, Paul]
Is list contains the student Tom?true
Is list contains the student Sudhir?false

Java Code Editor:

Previous: clone Method
Next: descendingIterator Method


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4