Online Java Compiler By
JavaTpoint.com
import java.util.Random; public class JavaRandomNextIntExample2 { static int j=1; public static void main(String[] args) { Random random = new Random(); for (int i=1;i<8;i++) { //return the next pseudorandom Integer value Integer val =random.nextInt(i); System.out.println(j++ +". Random intvalue : "+val+" "); } } }
Output