arrow_back Back to Notebook
java
java
January 10, 2019

The power of Stream.of() in Java

Stream.of() can be used instead of creating an array then iterating over it.

Java stream example

Stream.of(1,2,3).forEach(System.out::println);

Results in:

1

2

3

Even Better yet

If the order of execution does not matter you can execute Stream in .parallel()

Stream.of(1,2,3).parallel().forEach(System.out::println);

Results in an unpredictable output order such as:

3

1

2

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch