ServiceLoader stream() in Java

stream(): This method is available in java.util.ServiceLoader class of Java.

Syntax:

Stream<Provider<K>> java.util.ServiceLoader.stream()

This method returns a stream to lazily load available providers of this loader'sservice.

Parameters: NA

Returns: A stream that lazily loads providers for this loader's service.

Exceptions: NA

Approach

Java

import java.util.ServiceLoader;

public class ServiceLoaderstream {
    public static void main(String[] args) {

        ServiceLoader<String> serviceLoader =
ServiceLoader.load(String.class);

        System.out.println(serviceLoader.stream());

    }

}

Output:

java.util.stream.ReferencePipeline$Head@3cd1f1c8


No comments:

Post a Comment