From the stack trace, I see that this method is in a class called "TreeSet". So in main(), you're constructing an instance of this containing class, not the java.util.TreeSet you were expecting. Since Basic.TreeSet doesn't implement Set, boom. A ClassCastException.
It's always a bad idea to name a class after a class that appears in the core
Java APIs!