Question: Sorry again for knocking here again but I want to ask a final question. I found this code and it was not commented on. Can someone please comment it for me so that I can understand what the code is trying to do. Learning connection on my own. :(

```
public static void main(String[] args){

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Connection conn = null;

        try {  
          Class.forName("com.mysql.jdbc.Driver");
          conn = DriverManager.getConnection("jdbc:mysql://localhost/CLASS","root","sirikali1");
          Statement sqlState = conn.createStatement();
          String selectStuff = "select b.yearID, b.playerID from Student;

```

Answer: 
Your problem is in your comparison.

```
if (union.toString().contains(apiSwRepo.toString())) {
} else
    union.add(apiSwRepo);

```

In the above code, you are converting the Set to a String and then calling contains(). You instead should be .contains() on the union itself like so:

```
if (union.contains(apiSwRepo)) {
} else
    union.add(apiSwRepo);

```

I'd also like to suggest a simplification as follows:

```
union.retainAll(s2);

```

Because you have two Sets, you will get the union from that simple statement.
I don't know the reason yet. But I solved it making this changes to intersection method:

```
public <T> int intersection (Set<T> s1,Set<T> s2){

    Set<T> intersection = new HashSet<T>();
    for (T apiSwRepo:s2){
        if (s1.toString().contains(apiSwRepo.toString())){
            intersection.add(apiSwRepo);
        }           
    }
  return intersection.size();
}

```

As you can see, I did not use the `intersection.retainAll` because with my data it did not work, but with `Set<String>` test, it did. 

Just to be clear, my `data-set` was `API` information of a `HashMap` 

`HashMap<Integer, Set<API>> apisPerSystem = new HashMap<Integer, Set<API>>()`