Mega Code Archive

 
Categories / Java Tutorial / Development
 

Random integers that range from from 0 to n

import java.util.Random; public class Main {   public static void main(String[] argv) throws Exception {     Random rand = new Random();     int n = 10;     int i = rand.nextInt(n + 1);     System.out.println(i);   } }