Wednesday, February 22, 2012

Java Random number generation of 4 digits



import java.util.Random;

System.out.println("***** Generating Random Number of 4 digit *****");
Random random = new Random();
for(int i=0;i<100;i++){
    long fraction = (long)(1000 * random.nextDouble());
    int PIN= (int)(fraction + 1000);
    System.out.println(PIN);
 }

1 comment:

You can put your comments here (Either feedback or your Question related to blog)