Consider the following 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? } }
Which one of the following correctly describes the behavior of this program?
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.