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