next Random Int - Java java.util

Java examples for java.util:Random Int

Description

next Random Int

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int n = 2;
        System.out.println(next(n));
    }/*from  w ww. j  a v  a 2  s  .  co  m*/

    public static int next(int n) {
        return (int) (Math.random() * n);
    }
}

Related Tutorials