0
Can we use both push and pop in both queue and stack???
4 Respostas
+ 2
Minishreddy Vaidhyula you can , they are just names ,changing the function name won't change the functionality !!
But if someone expects you to have name of the methods as push and pop then you can't obviously use any name for it.
+ 1
Don't we already use it ?
In queue we push element from the front while in stack we push element from the back.
In queue we remove(pop) element from the front while in stack we remove element from the back.
There can be different implementation of both but that's how it works.
+ 1
you can, but Queue in java api has add() and remove() instead
0
Can we use add in the place of push in both queue and stack ??