Java Collection Tutorial - Java BlockingDeque.contains(Object o)








Syntax

BlockingDeque.contains(Object o) has the following syntax.

boolean contains(Object o)

Example

In the following code shows how to use BlockingDeque.contains(Object o) method.

/*  w w  w  . j a  va2  s.  co  m*/
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Main {
  public static void main(String[] argv) throws Exception {
    int capacity = 10;
    BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
      queue.add(i);
    }
    
    System.out.println(queue.contains(0));
  }
}

The code above generates the following result.