📜  如何在java代码示例中创建一个随机数

📅  最后修改于: 2022-03-11 14:52:37.308000             🧑  作者: Mango

代码示例6
Random random = new Random();
long v1 = random.nextInt();
long v2 = random.nextInt();
for (int i = 0; i < 65536; i++) {
    long seed = v1 * 65536 + i;
    if (((seed * multiplier + addend) & mask) >>> 16) == v2) {
        System.out.println("Seed found: " + seed);
        break;
    }
}