Online Java Compiler By
JavaTpoint.com
import java.util.Collections; import java.util.Iterator; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedTransferQueue; public class LinkedTransferQueueIteratorExample3 { public static void main(String[] args) { Integer[] val = {0, 1}; LinkedTransferQueue
queue = new LinkedTransferQueue
(); queue.add(71018); queue.add(8000); queue.add(1178); queue.add(1190); //Returns an iterator over the elements Iterator
iterator = queue.iterator(); while(iterator.hasNext()){ System.out.println(iterator.next()); val[0] = Collections.max(queue); val[1] = Collections.min(queue); } System.out.println("Max number = "+ val[0]); System.out.println("Min number = "+ val[1]); } }
Output