title: Triangle recursion
body: <p>So i have a program in which (with recursion) i am supposed to take a user input (int) and draw a backward and then forward triangle according to the number... ex below</p>
  
  <p>User input: 4
  (ignore the extra spaces inbetween each,, there should be no extra line inbetween) Result:</p>
  
  <pre><code>XXXX 
  XXX
  XX
  X
  X
  XX
  XXX
  XXXX
  </code></pre>
  
  <p>I have created a method in which i think should do it but I am having a problem wiht it</p>
  
  <p>This si the code I have so far</p>
  
  <p>n is the input number
  z is a counter to try and go between making a backwards/ forwards triangle</p>
  
  <pre><code>    public static String drawLine(int n, int z){
  
              if(n!=0&amp;&amp; z&lt;(n+1)){
                  for(int i=1;i&lt;=n;i++)
                      System.out.print("X");
                  System.out.println();
                  z+=1;
                  drawLine(n-1,z);
  
                  return"";
              } 
              else{
              if( z==(2*n+1) ) return "";
              z+=1;
              String p = drawLine(n - 1,z);
              p = p + "X";
              System.out.println(p);
  
  
             return p;    }
  
              }
  </code></pre>
  
  <p>the error message is that there is some infinit loop or an over flow, but I cannot find the error....please help!!</p>