Java随机生成数字
Java 生成随机数常用的生成方式:1、使用Random类,下面的方式可以生成0-10000的整数,不包括10000,但不一定是四位数Random random = new Random();System.out.println("---------"+random.nextInt(10000) );2、Math.random()9000+1000 或 (int)((Math.random()9+1)*1000)System.out.println((int)((Math.random()9+1)1000)); 说明:Math.random()取值范围是[0,1) Math.r...
最近评论