ServiceLoader toString() in Java

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

Syntax:

String java.util.ServiceLoader.toString()

This method takes one argument. This method returns a string describing this service.

Parameters: NA

Returns: A descriptive string.

Exceptions: NA

Approach

Java

import java.util.ServiceLoader;

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

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

        System.out.println(serviceLoader.toString());
    }

}

Output:

java.util.ServiceLoader[java.lang.String]


No comments:

Post a Comment