Creating a set of sub-sets of size K  from a given  interval- using Set In Java
<p>I'd love your help with this following problem:</p>

<p>I want to write in Java a method that will gets three values: first, last and K, so and creates all the sub-sets of size L of numbers within the bounded interval [first,last],</p>

<p>For example: If first=1, last=3 and K=2, so the result will be {1,2},{1,3},{2,3}.</p>

<p>Ok, So I decided that the result value of the function will be <code>Set&lt;Set&lt;Integer&gt;&gt;</code> , But I'm not sure of how exactly I need to do that, What is the algorithm and the right way to write it.</p>

<pre><code>public static Set&lt;Set&lt;Integer&gt;&gt; generateKsubsets( 
int first, int last, int K){
Set&lt;Set&lt;Integer&gt;&gt; result = new HashSet&lt;Set&lt;Integer&gt;&gt;(); 
</code></pre>

<p>question 1: Is this the right Implemention of set to use in this case? 
To be honest, I'm not sure why do I use it here. Can I use here HasgTree? Is there any difference between theme in this case?</p>

<pre><code>If(K==0) {
</code></pre>

<p>question 2:
   So here I would Like to return an empty set of the type that I defined,
 How should I do that?Can 
I add an empty set into the result set? </p>

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

<p>And now the main question(3): I can't understand how my algorithm should work and how should I write it using this set.</p>

<p>Thank you for the help.</p>
