title: How to print every third character of a string? java
body: <p>I am trying to print every 3rd character of a string so an example would be:
    <code>123456</code> returns <code>36</code></p>
  
  <p>But my code below returns <code>14</code></p>
  
  <pre class="lang-java prettyprint-override"><code>public String getEveryThird() {
      String newString = "";
  
      for (int i = 0; i &lt; string.length(); i++) {
  
          if (i % 3 == 0) {
              newString += (string.charAt(i));
          }
      }
  
      return newString;
  }
  </code></pre>