Java ArrayBlockingQueue .contains (Object o)
Syntax
ArrayBlockingQueue.contains(Object o) has the following syntax.
public boolean contains(Object o)
Example
In the following code shows how to use ArrayBlockingQueue.contains(Object o) method.
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
// ww w . j a v a 2 s . com
public class Main {
public static void main(String[] argv) throws Exception {
int capacity = 100;
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);
for (int i = 0; i < 100; i++) {
queue.add(i);
}
System.out.println(queue.contains(5));
queue.clear();
System.out.println(queue.contains(5));
}
}
The code above generates the following result.