Get Random number between 0 AND 10 in Java
Description
The following code shows how to get Random number between 0 AND 10.
Example
/*from w w w . j a v a2 s. com*/
import java.util.Random;
public class Main {
public static void main(String[] argv) {
Random r = new Random();
int randint = Math.abs(r.nextInt()) % 11;
System.out.println(randint);
}
}
The code above generates the following result.