1、random.nextInt(num)
public static void main(String args[]) { Random rdom = new Random(); int max = 1314; int min = 520; for(int i = 0;i<2000;i++){ int count = rdom.nextInt((max - min + 1)) + min; if(count==1313){ System.out.println("1313=================>>>"+count); }else if (count==520){ System.out.println("520=================>>>"+count); }else if(count<520 || count>1313){ System.out.println("error=================>>>"+count); }else{ System.out.println("success=================>>>"+count); } } }