package mypackage;
import java.security.SecureRandom;
import java.util.Random;
public class SecureRandomTest {
/**
* @param args
*/
public static void main(String[] args) {
SecureRandom sr1 = new SecureRandom();
System.out.println("1. SecureRandom object 1. nextInt() result :" + sr1.nextInt());
System.out.println("1. SecureRandom object 2. nextInt() result :" + sr1.nextInt());
System.out.println("1. SecureRandom object 3. nextInt() result :" + sr1.nextInt());
System.out.println("1. SecureRandom object 4. nextInt() result :" + sr1.nextInt());
System.out.println("1. SecureRandom object 5. nextInt() result :" + sr1.nextInt()+"\n\n\n");
SecureRandom sr2 = new SecureRandom();
System.out.println("2. SecureRandom object 1.nextInt() result :" + sr2.nextInt()+"\n\n\n");
Random r1 = new Random();
System.out.println("1. Random object 1. nextInt() result :" + r1.nextInt());
System.out.println("1. Random object 2. nextInt() result :" + r1.nextInt()+"\n\n\n");
Random r2 = new Random();
System.out.println("2. Random object 1. nextInt() result :" + r2.nextInt());
}
}
The output is :
1. SecureRandom object 1. nextInt() result :2081492090
1. SecureRandom object 2. nextInt() result :1073396477
1. SecureRandom object 3. nextInt() result :134130488
1. SecureRandom object 4. nextInt() result :-1229020596
1. SecureRandom object 5. nextInt() result :-679432773
2. SecureRandom object 1.nextInt() result :1924631447
1. Random object 1. nextInt() result :1121875770
1. Random object 2. nextInt() result :-486804200
2. Random object 1. nextInt() result :1910565042
So what is the difference? I can't see any difference between these two...