Answer:
Check the explanation
Step-by-step explanation:
CODE:
static int findEvenQueue(Queue<Integer> numbers)
{
//loop runs till the queue has atleast one element
while(numbers.size() > 0)
{
//Checking the head of the queue whether it is even
int temp = numbers.peek();
if(temp % 2 == 0)
{
//if the head is even then return it
return temp;
}
else
{
//else remove the number at head
int removed = numbers.poll();
}
}
//if no even number present in the Queue then return -1
return -1;
}