We have seen some portion of this code in other your
thread. Could you please copy and paste full code with the right formatting?
I find your code difficult to read, don't know exactly why. Formatting most likely is the first in the queue. Noise of comments is another.
1. If your intention is not to have duplicate values in the data structure - use right data structure which ensures that. If insertion order matters, use data structure which ensures there are no duplicates + which maintains insertion order. If in the final end such data structure needs to be List, convert it to List after you ensured there are no duplicates and order maintained. That way your intention would be much clearer rather than check if List contains element or not and then decide whether add such element or not.
So, this:
Change to:
2. Don't name variables as "list". At most it tells you about implementation details and nothing else. You need more than that, in fact implementation details you don't need to know. You need to know, that "list" holds random integers, so call it "randomIntegers" - much better, isn't it?
3. Avoid writing comments which tell nothing. This code snippet contains only 1 comment, but in your other thread code contained lots of comments which were all less of a use and misleading.
4. Formatting formatting formatting. Important!
For the question at hand, what is the briefcases array length? It might can't hold so many elements as you are trying to add.