title: Printing array of char in java in matrix-like form
body: <p>I am writing a program to display an array of <code>char</code> in rows and columns(see below). But, the output of my code right now is like so:</p>
  <pre><code>hhhhehehehelhelhelhellhellhell
  </code></pre>
  <p>What i want to display is this:</p>
  <pre><code>h e l l
  o w o r
  l d n e
  w d a y
  </code></pre>
  <p>And here's my current code:</p>
  <pre><code>String str = &quot;helloworldnewday&quot;; 
  
    double length = Math.sqrt(str.length());
    int x = (int) length;
  
    char[] ch = new char[str.length()]; 
  
    for (int i = 0; i &lt; x; i++) { 
      for (int j = 1; j&lt; x; j++){
        ch[i] = str.charAt(i); 
        System.out.print(ch);
      } 
    } 
  </code></pre>
  <p>I know my code is terrible because I just began learning. Can you guys tell me what's wrong with my code? I appreciate every answer. Thank you.</p>