nextBoolean(): This method is available in java.util.Random class of Java.
Syntax:
boolean java.util.Random.nextBoolean()
This method returns the next pseudorandom, uniformly distributed boolean value from this random number generator'ssequence.
Parameters: NA
Returns: the next pseudorandom, uniformly distributed boolean value from this random number generator sequence.
Exceptions: NA
Approach
Java
import java.util.Random;public class RandomnextBoolean {public static void main(String[] args) {Random random = new Random();System.out.println(random.nextBoolean());}}
Output:
true
No comments:
Post a Comment