Given a string, S, of length N that is indexed from 0 to N1, I want to print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line:Hacker -> Hce akrMy code works, but I feel it could have been done more elegantly and maybe in a single stream instead of in two... Any ideas how to improve this?private static String reindex(String input) {    StringBuilder result = new StringBuilder();    IntStream.range(0, input.length())             .filter(index -> index % 2 == 0)             .forEach(index -> result.append(input.charAt(index)));    result.append( );    IntStream.range(0, input.length())             .filter(index -> index % 2 == 1)             .forEach(index -> result.append(input.charAt(index)));    return result.toString();}
Printing alternating characters of a string using Java 8 streams
java;strings;stream