I am wondering if calling the pop()
method from the Stack
data structure within an if statement will pop off the first element from the stack?
Here is an example of code:
public void pop() {
if(stack.pop() == min) min=stack.pop();
}
Will this work? Or is it better to declare it like so:
public void pop() {
int poppedOff = stack.pop();
if(poppedOff == min) min=stack.pop();
}
I am assuming these are doing the same things but I am not completely sure.