How to use empty() in IntStream?

Here is an example to explain how to use empty() in IntStream.

Syntax:

Modifier and Type         		Method
static IntStream                empty()

The IntStream.empty returns an empty sequential IntStream.

package com.nourit.java8.Streams.IntStream;

import java.util.stream.IntStream;

public class IntStreamEmpty {

  public static void main(String[] args) {
    System.out.println("---------- Empty Example  -----------------");
    //Returns a stream consisting of the distinct elements of this stream.
    IntStream emptyStream = IntStream.empty();
    System.out.println(emptyStream.count());
    System.out.println("---------------------------------------");
  }
}

Output:

---------- Empty Example  -----------------
0
---------------------------------------

 

NOUR-IT

IT Training Center for Java and Web technology. If you enjoy and like our tutorials and believe in our mission, Please Subscribe us on Youtube and follow us on Twitter, or befriend us on Facebook or Google Plus.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*