Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; public class JavaDequecontainsExample2 { public static void main(String[] args) { Deque
deque = new ArrayDeque<>(); System.out.println("The list of the elements is given as : "); deque.add('A'); deque.add('J'); deque.add('M'); deque.add('O'); System.out.println("The final result of the deque is given as : "+deque); boolean b1 = deque.contains('Z'); if(b1==true) { System.out.println("The first element is in the list."); } else { System.out.println("The first element is not in the list."); } boolean b2 = deque.contains('I'); if(b2==true) { System.out.println("The second element is in the list."); } else { System.out.println("The second element is not in the list."); } } }
Output