You have some Queue<E> someQ = new Queue<E>()
invalid syntax, Queue is an interface so you cannot use the new
key word in java to make a new object of it.
if you are determining the size, then use the size() method.
comparing head == null is an alternative since peek, peekFirst method returns a null when the array is empty, but I think that is not 100% accurate. why?
what if I have a Queue of String generic. and I pushed these values:
the top of stack in Queue is null
so if you are determining if the Queue is empty using head == null, then you can conclude that the above Queue is empty, but actually not, it returns a null
just because its top of stack is null, but actually it has 3 elements.