Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; public class JavaDequecontainsExample1 { public static void main(String[] args) { Deque<Float> deque = new ArrayDeque<>(); System.out.println("The list of the elements is given as : "); deque.add(45f); deque.add(31f); deque.add(456f); deque.add(29f); System.out.println("The final result of the deque is given as : "+deque); boolean b1 = deque.contains(45f); 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(100f); 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