import java.util.Random; public class RandomIntegers { public static void main(String[] args) { Random random = new Random(); int randomInt = random.nextInt(101); // generates random integers between 0 to 100 System.out.println(randomInt); } }
import java.util.Random; public class RandomBoolean { public static void main(String[] args) { Random random = new Random(); boolean randomBoolean = random.nextBoolean(); System.out.println(randomBoolean); } }
import java.util.Random; public class RandomDouble { public static void main(String[] args) { Random random = new Random(); double randomDouble = random.nextDouble(); System.out.println(randomDouble); } }These examples show how to use the java.util.Random package to generate random values in Java.