getR static method

int getR(
  1. int x
)

在[0,x)之间获得随机数,如果想从1开始,那对结果+1即可

Implementation

static int getR(int x) {
  return Random().nextInt(x);
}