1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| package com.ruben;
import com.baomidou.mybatisplus.extension.api.R;
import java.util.Random; import java.util.Spliterators; import java.util.stream.IntStream; import java.util.stream.StreamSupport;
public class RandomDemo { public static void main(String[] args) { Random random = new Random(); for (int i = 20; i > 0; i--) { System.out.print(random.nextInt(200)); } System.out.println(); Random seedRandom = new Random(80); for (int i = 20; i > 0; i--) { System.out.print(seedRandom.nextInt(200)); } System.out.println(); new Random().ints(20, 0, 200).forEach(System.out::print); System.out.println(); IntStream intStream = StreamSupport.intStream(Spliterators.spliterator(new int[]{1, 2, 3}, 3), false); intStream.forEach(System.out::print); System.out.println(); for (int i = 20; i > 0; i--) { System.out.print(IntStream.range(0, 200).parallel().findAny().orElse(0)); } System.out.println(); }
}
|