title: ZigZag line in Java
body: <p>I'm trying to make a ZigZag line in Java using chars but the code isn't working</p>
  
  <pre><code>public void ZigZag(int width, int height, boolean infinite, char ch){
      System.out.println(ch);
      for (int j = 0; j &lt; height; j++) {
          for (int i = 1; i &lt; width; ++i)
              printline(i);
          for (int i = width - 1; i &gt;= 0; --i)
              printline(i);
      }
  }
  
  void printline(int i, char ch) {
      for (int k = 0; k &lt; i; k++)
          System.out.print(" ");
      System.out.println(ch);
  }
  </code></pre>
  
  <p>P.S The user inputs the char and the program makes zigzag using that char</p>
  
  <p><img src="https://i.stack.imgur.com/fLVR1.png" alt="Pic"></p>