Online Java Compiler By
JavaTpoint.com
import java.util.Iterator; import java.util.concurrent.LinkedTransferQueue; public class LinkedTransferQueueContainsExample1 { static int i=1; public static void main(String[] args) { LinkedTransferQueue
queue = new LinkedTransferQueue
(); queue.add("Jack"); queue.add("Harry"); queue.add("Kristan"); queue.add("John"); Iterator
iterator = queue.iterator(); //Returns an iterator over the elements while(iterator.hasNext()){ System.out.println(i++ +"."+iterator.next()); } /*contains() method will return a boolean value if the specified object is present in the queue*/ if(queue.contains("John")) { System.out.println("John is present"); } else{ System.out.println("John is absent"); } } }
Output