title: Java 8 convert integers to String with Lambda
body: <p>I'm trying to create a function which returns a random string of alphabetic characters, but I'm trying to do it using lambdas, my function looks like:</p>
  
  <pre><code>public static String nextString() {
    return IntStream.range(0, 10).map(i -&gt; getRandomChar()).XXX
  }
  
  private static Character getRandomChar() {
    //returns a random Character object
  }
  </code></pre>
  
  <p>I don't know what to set on XXX.</p>
  
  <p>I fixed it in a similar way by doing:</p>
  
  <pre><code>public static String nextString() {
      StringBuilder randomString = new StringBuilder();
      IntStream.range(0, stringLenght).forEach(i -&gt; randomString.append(getRandomChar()));
      return randomString.toString();
  }
  </code></pre>
  
  <p>But I'd prefer not to create a new StringBuilder each time the method is used and keep states and variables for a simple method.</p>