(Stack<Integer> s, int data)
| 2 | //To push an element at the bottom of a stack |
| 3 | public class Question1 { |
| 4 | public static void pushAtBottom(Stack<Integer> s, int data) { |
| 5 | if(s.isEmpty()) { |
| 6 | s.push(data); |
| 7 | return; |
| 8 | } |
| 9 | |
| 10 | int temp = s.pop(); |
| 11 | pushAtBottom(s, data); |
| 12 | s.push(temp); |
| 13 | } |
| 14 | |
| 15 | public static void main(String args[]) { |
| 16 | Stack<Integer> stack = new Stack<>(); |