What does a Push operation on a stack return?
A:
That depends entirely on the stack implementation, I think. Some implementations might return nothing, others a boolean value, others still the stack object itself for chaining:
stack.push(element1).push(element2);
Tom Bartel
2009-11-10 09:02:00
+1
A:
This would depend on the implementation.
Push doesn't usually return anything as it adds an item you supply to the stack. The corresponding Pop operation would remove the item from the top of the stack and return it.
GraemeF
2009-11-10 09:02:35
+1
A:
It's not supposed to return anything. In .Net it's defined as a void function, for example.
Traveling Tech Guy
2009-11-10 09:02:47
what does it returns in Java?
vaibhav
2009-11-10 09:09:46
It returns the object you just pushed: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html#push%28java.lang.Object%29
Traveling Tech Guy
2009-11-10 09:23:09