如何between 0 and 2^32-1
在java中生成随机数?我写这个链接:
long[]num = new long[size + 1];
Random random = new Random();
for (int i = 1; i < size + 1; i++) {
num[i] = (long)random.nextInt()+(long)(1<<31);
System.out.println(num[i]);
}
但它打印
-1161730240
-1387884711
-3808952878
-3048911995
-2135413666
我不知道为什么..