Here you can find the source of getRandom(int p)
Parameter | Description |
---|---|
p | p |
public static int getRandom(int p)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ThreadLocalRandom; public class Main { /**// ww w. j a va 2 s . c o m * Generator an random int by 10^(p-1) * Use nextInt(int origin, int bound) in JDK 1.7 * @param p p * @return random int */ public static int getRandom(int p) { if (p <= 0 && p > 9) return -1; return ThreadLocalRandom.current().nextInt((int) Math.pow(10, p - 1), (int) Math.pow(10, p) - 1); } }