Get an Element Is Exists in Java Deque Example

Get an Element Is Exists in Java Deque Example


Posted in : Java Posted on : December 1, 2010 at 4:25 PM Comments : [ 0 ]

This Java Example shows how to know that an element is exists in the specified Deque.

Get an Element Is Exists in Java Deque Example

This Java Example shows how to know that an element is exists in the specified Deque. To get the element from Deque object we use boolean contains(E element) method. This method returns true if Deque contains the specified element otherwise returns false.

 Example: ContainsElementInDeque.java

package devmanuals.com;

import java.util.*;

public class ContainsElementInDeque {
	public static void main(String args[]) {

		Deque queue = new ArrayDeque();

		queue.add("A");
		queue.add("B");
		queue.add("C");
		queue.add("D");
		boolean contain = queue.contains("C");
		System.out.println("The Deque elements are : " + queue);
		System.out.println("Is the Deque have C : " + contain);
	}
}

Output:

The Deque elements are : [A, B, C, D] 

Is the Deque have C : true

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics