Choose the correct option based on this program:.
import java.util.*; public class Main { public static void main(String []args) { Deque<Integer> deque = new ArrayDeque<>(); deque.addAll(Arrays.asList(1, 2, 3, 4, 5)); System.out.println("The removed element is: " + deque.remove()); // ERROR? }/*w w w. java2s .c om*/ }
remove()
returns void" for the line marked with the comment ERROR.InvalidOperationException
.B.
the remove()
method is equivalent to the removeFirst()
method, which removes the first element (head of the queue) of the Deque object.