QUESTION
How come this code here:
Object y=x.remove();
removes the object from the queue?
Isn't this just a variable assignment. Why does it run the code, when we are not calling it? Does variable deceleration call the methods as well?
Queue<Integer> x = new LinkedList<Integer>();
x.add(5);
x.add(7)
Object y=x.remove(); //<------THIS
x.add(4)
System.out.println(x.element());