Online Java Compiler By
JavaTpoint.com
import java.util.Random; public class JavaRandomExample2 { public static void main(String[] args) { Random random = new Random(); //return the next pseudorandom integer value System.out.println("Random Integer value : "+random.nextInt()); // setting seed long seed =20; random.setSeed(seed); //value after setting seed System.out.println("Seed value : "+random.nextInt()); //return the next pseudorandom long value Long val = random.nextLong(); System.out.println("Random Long value : "+val); } }
Output