Random toString() in Java

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

Syntax:

String java.lang.Object.toString()

This method returns a string representation of the object.

Parameters: NA

Returns: a string representation of the object.

Exceptions: NA

Approach

Java

import java.util.Random;

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

        Random random = new Random();

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

Output:

java.util.Random@4361bd48


No comments:

Post a Comment