long startTime;
long endTime;
int times = 8000000;
Random rand = new Random();
startTime = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
int a = rand.nextInt(5);
//System.out.println(a);
}
endTime = System.currentTimeMillis();
System.out.println("Random.nextInt(): " + (endTime - startTime));
startTime = System.currentTimeMillis();
for (int i = 0; i < times; i++) {
int a = (int)(Math.random() * 5);
}
endTime = System.currentTimeMillis();
System.out.println("Math.random(): " + (endTime - startTime));