In this example we will show you how to use math.random() to return a random number between 0 and 1 in Java.
Source Code
package com.beginner.examples;
public class Random {
public static void main(String[] args) {
System.out.println(Math.random()); // return a random number between 0 and 1
}
}
Output:
0.03371932752330553