Manuel :
I've an issue that I couldn't fix, I tried different ways. I filled an Array with ok 100 positions with randoom numbers (Range: 1-100). Then I've to show by console the numers that aren't incluides in the array. I try two loopes nested but it didn't work neither.
int arraySize = 100, aux=0;
int numeros [] = new int [arraySize];
for (int i = 0; i < numeros.length; i++) {
numeros[i] = (int) ((Math.random()*100)+1);
Here, Somebody know how to get it? Thanks
Mureinik :
I'd just stream all the numbers and check which ones aren't included in the array. Note that in order to get better performance it may be useful to convert the array to a Set
, but it isn't strictly required:
Set<Integer> existing = Arrays.stream(numeros).boxed().collect(Collectors.toSet());
IntStream.rangeClosed(1, 100)
.boxed()
.filter(i -> !existing.contains(i))
.forEach(System.out::println); // or collect them to use later
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=296466&siteId=1