生成随机数:
代码案例:
/** * Random类:生成随机数 * * */ public class RandomDemo01 { public static void main(String[] args) { Random random=new Random(); System.out.println(random.hashCode());// int i=random.nextInt(); System.out.println(i);//2095820655 double b=random.nextDouble(); System.out.println(b);//0.9803179250903287 float f=random.nextFloat(); System.out.println(f);//0.23888469 long l=random.nextLong(); System.out.println(l);//-7290130819150049334 } }