import java.io.*; import java.util.Random; public class Test { public static void main(String args[]) throws IOException { int i1; Random rn = new Random(123); System.out.println("乱数の生成(初期値:123)"); for (i1 = 0; i1 < 5; i1++) System.out.println(" " + rn.nextInt() + " " + rn.nextDouble()); System.out.println("初期値の再設定:123"); rn.setSeed(123); for (i1 = 0; i1 < 5; i1++) System.out.println(" " + rn.nextInt() + " " + rn.nextDouble()); } }
乱数の生成(初期値:123) -1188957731 0.2372439353301956 1295249578 0.25329310557439133 -1680189627 0.258881521312438 -1621910390 0.8754127852514174 -1219562352 0.1622156958567652 初期値の再設定:123 -1188957731 0.2372439353301956 1295249578 0.25329310557439133 -1680189627 0.258881521312438 -1621910390 0.8754127852514174 -1219562352 0.1622156958567652