Java 8: Infinite Stream of UUIDs

import java.util.UUID;
import org.junit.Test;

public void infiniteUUIDStream() {
   Stream<String> uuidStream = Stream.
		   map(u -> u.toString());


Now you only need a few asserts to verify that the infinite Stream only comprises unique values :-)

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home:

Web Apps, SPA, PWA with vanilla Java Script (ES 6+), CSS 3 and WebStandards only. As simple as possible, but not simpler. See you at: (Progressive) Web apps, Single Page Apps and WebStandards airhacks workshops at MUC airport, Winter Edition the podcast:

Stay in touch:


It's always a pleasure to read your blog . Has inspired me to start today the new NetBeans IDE and to experiment with your example .

Posted by Bernd on November 25, 2015 at 09:59 AM CET #


We can also replace u -> u.toString() with UUID::toString


Posted by Philip Schwarz on November 26, 2015 at 09:31 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments