Using a stream to iterate n times instead of using a for loop to create n items April 15, 2023 by Tarik You could use Stream#generate with limit: Stream.generate(MyClass::new).limit(10);