/**
 * Company
 * Copyright (C) 2014-2017 All Rights Reserved.
 */
package com.cwenao.trying.stackandqueue;

/**
 * Using two recursion to reverse the stack
 * @author cwenao
 * @version $Id ReverseStackWithRecursion.java, v 0.1 2017-10-05 22:46 cwenao Exp $$
 */
public class ReverseStackWithRecursion {
}

@@ -102,16 +102,41 @@
 queue;%0A%0A
+import java.util.Stack;%0A%0A
 /**%0A * U
@@ -175,16 +175,19 @@
 e stack%0A
+ *%0A
  * @auth
@@ -285,16 +285,16 @@
  $$%0A */%0A
-
 public c
@@ -325,11 +325,783 @@
 ursion %7B
+%0A%0A    private static Stack%3CInteger%3E stack = new Stack%3C%3E();%0A%0A    private static void insertAtBottom(int x) %7B%0A        if (stack.isEmpty()) %7B%0A            stack.push(x);%0A        %7D else %7B%0A            int a = stack.peek();%0A            stack.pop();%0A            insertAtBottom(x);%0A            stack.push(a);%0A        %7D%0A    %7D%0A%0A    public static void reverseStack() %7B%0A        if (stack.size()%3E0) %7B%0A            int a = stack.peek();%0A            stack.pop();%0A            reverseStack();%0A            insertAtBottom(a);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        stack.push(1);%0A        stack.push(2);%0A        stack.push(3);%0A        stack.push(4);%0A        stack.push(5);%0A        stack.push(6);%0A%0A        reverseStack();%0A%0A        System.out.println(stack);%0A%0A    %7D
 %0A%7D%0A

update the reverse stack class