Generating all subsets of a given set
The first, obvious, issue is that generating the set in memory uses a lot of memory. However, making a lazy version is a bit more advanced, so don't worry about it for now.

1. Code to the interface, not the implementation

public static HashSet&lt;HashSet&lt;Integer&gt;&gt; generateAllSubsets(Set&lt;Integer&gt; original) {


is bad.

public static Set&lt;Set&lt;Integer&gt;&gt; generateAllSubsets(Set&lt;Integer&gt; original) {


is better.

2. Generics reduce repetition

public static &lt;T&gt; Set&lt;Set&lt;T&gt;&gt; generateAllSubsets(Set&lt;T&gt; original) {


is better still, because you can use it to find power sets of any set.

3. Generics remove the necessity to do most casts

    Iterator it = original.iterator();
    while(it.hasNext()) {
        Integer element = (Integer) it.next();


and

        Iterator it2 = tempClone.iterator();
        while(it2.hasNext()) {
            Set&lt;Integer&gt; s = (HashSet&lt;Integer&gt;) it2.next();


have wholly unnecessary explicit casts (which in the second case generates a warning) because you're using the raw type Iterator. Both can also be simplified using the same foreach syntax which you use when making the copy of the power set so far.

4. KISS

You have three loops (including the one hidden behind allSubsets.addAll), which seems to me to be unnecessarily complicated. If you make a shallow copy first then you can combine the deep copy with the adding an element.

public static &lt;T&gt; Set&lt;Set&lt;T&gt;&gt; generateAllSubsets(Set&lt;T&gt; original) {
    Set&lt;Set&lt;T&gt;&gt; allSubsets = new HashSet&lt;Set&lt;T&gt;&gt;();

    allSubsets.add(new HashSet&lt;T&gt;()); //Add empty set.

    for (T element : original) {
        // Copy subsets so we can iterate over them without ConcurrentModificationException
        Set&lt;Set&lt;T&gt;&gt; tempClone = new HashSet&lt;Set&lt;T&gt;&gt;(allSubsets);

        // All element to all subsets of the current power set.
        for (Set&lt;T&gt; subset : tempClone) {
            Set&lt;T&gt; extended = new HashSet&lt;T&gt;(subset);
            extended.add(element);
            allSubsets.add(extended);
        }
    }

    return allSubsets;
}


You'll note that I'm using the copy-constructor rather than clone(). That's a matter of taste: fundamentally there's no real difference, because they're both special-cased.