Java ThreadLocalRandom class
import java.util.concurrent.ThreadLocalRandom; public class Main { public static void main(String[] args) { System.out.println(ThreadLocalRandom.current().nextInt(10)); System.out.println(ThreadLocalRandom.current().nextInt(10)); System.out.println(ThreadLocalRandom.current().nextInt(10)); System.out.println(ThreadLocalRandom.current().nextInt(10)); System.out.println(ThreadLocalRandom.current().nextInt(10)); }/*from w w w . jav a 2 s .co m*/ }
import java.util.concurrent.ThreadLocalRandom; public class Main { public static void main(String[] args) { System.out.println("Five random integers"); for (int i = 0; i < 5; i++) { System.out.println(ThreadLocalRandom.current().nextInt()); }//from ww w .j a va2s .co m System.out.println(); System.out.println("Random double number between 0.0 and 35.0"); System.out.println(ThreadLocalRandom.current().nextDouble(35.0)); System.out.println(); System.out.println("Five random Long numbers between 1234567 and 7654321"); for (int i = 0; i < 5; i++) { System.out.println(ThreadLocalRandom.current().nextLong(1234567L, 7654321L)); } } }