How to auto generate overlapping integers in a certain range
<pre><code>If the number range is 0 - 10. I would like to generate the following numbers

e.g. 

unique 5 numbers [3, 8, 5, 1, 9]
unique 3 numbers [2, 6, 5]
5 numbers of which 2 numbers occur twice [2, 3, 2, 6, 3]
7 numbers of which 2 numbers occur twice [2, 5, 9, 2, 7, 5, 3] (Here 2, 5 occur twice)
5 numbers of which 1 number occur thrice [2, 3, 8, 3, 3] (Here 3 occurs twice)
7 numbers of which 1 number occur thrice and 1 number occurs twice [1, 5, 9, 1, 1, 5, 3] (Here 1 occurs thrice, 5 occurs twice)
</code></pre>

<p>How would you implement a generic function which caters to the above requirements.</p>

<p>EDIT1:</p>

<p>This is what I have right now..</p>

<pre><code>protected List&lt;Integer&gt; fetchOverlapIntegers(int min, int max,
        int howMany, int overlap) {
    // The following code fetches unique numbers within the range
    List&lt;Integer&gt; numbers = this.fetchRandomIntegers(min, max, howMany);

    if (overlap &gt; 0) {
        int size = numbers.size();
        for (int i = 0; i &lt; overlap; i++) {
            numbers.set(size - 1 - i, numbers.get(i));
        }
    }
    Collections.shuffle(numbers);

    return numbers;
}
</code></pre>
