Repeating Text n Times via Stream.generate()

There are several approaches for repeating a string n times. In functional-style, we can rely on Stream.generate(), as in the following example:

String result = Stream.generate(() - TEXT)   .limit(5)    .collect((joining()));
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: