获取[x-y]区间的随机数: 公式 [x-y]区间的随机数 int num = (int) (Math.random() * (y - x + 1) + x); 注意: Math.random 默认返回 double 类型 所以 用int转