First, your Vehicle class is designed incorrectly.
1. Your setters are not setting anything but returning something. Setters should not be static
and should have a return type of void.
2. You need to add some getters to properly get the value. They should not be static either.
3. Implementing Comparable is fine and I believe you did it okay. But it is not required. You could also
have defined a Comparator for Vehicle and passed it to the TreeSet constructor as follows:
Comparator<Vehicle> comp = Comparator.comparing(Vehicle::getSpeed);
// then later
TreeSet<Vehicle> set = new TreeSet<>(comp);
Regards,
Jim