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 ...

Get Reactive Programming With Java 9 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.