[Solved] Java poll() inside if statement


Yes – poll removes the first item in the list and returns it.
This will then be evaluated in your if statement.

On an unrelated note, it is worth mentioning that the size of edges will obviously change on every loop since polling edges reduces the element count by one. However, your for loop evaluates the size of edges exactly once – on entry. A better way to implement this would be to use a while loop, for example.

int i = 0;

while(i<edges.size())
{
    if(edges.poll() == 5)
    {
        break;
    }
    i++
}

solved Java poll() inside if statement