Mega Code Archive

 
Categories / Java Tutorial / Development
 

Create two random number generators with the same seed

import java.util.Random; public class Main {   public static void main(String[] argv) throws Exception {     Random rand = new Random();     long seed = rand.nextLong();     rand = new Random(seed);     Random rand2 = new Random(seed);   } }