Skip to content
Advertisement

Simplest way to print an `IntStream` as a `String`

With Java-8 I can easily treat a String (or any CharSequence) as an IntStream using either the chars or the codePoints method.

JavaScript

I can then manipulate the contents of the stream

JavaScript

I have been hunting for a tidy way to print the results and I cant even find a simple way. How do I put this stream of ints back into a form that can be printed like I can a String.

From the above stars I hope to print

JavaScript

Advertisement

Answer

JavaScript

But still, "Hello world.".replaceAll("[^ ]", "*") is simpler. Not everything benefits from lambdas.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement