O'Reilly logo

Reactive Programming With Java 9 by Tejaswini Mandar Jog

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streams in action

The moment we say Stream, we developers start visualizing I/O Streams. You are on the right track, but the only thing is such Streams only handle bytes, while Java 8 Streams can either be of type bytes or object. Consider the following code snippet, which reads a number from the user:

    Scanner scanner=new Scanner(System.in); 
    System.out.println("Enter your age"); 
    int age=scanner.nextInt(); 

If you execute the preceding code your console will show Enter your age as an output and the application thread is then stuck. Why? The thread got suspended because it needs input from the user to resume execution of the remaining code. Unless the user provides an input the next statement will not execute. You must be wondering, what am ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required