<Write a Copyable interface more elegant than in J...
# stackoverflow
u
Write a Copyable interface more elegant than in Java I'm trying to write an interface that classes can implement to make them "copyable", a (type)safe Clonable. In Java, I would do something like this, using recursive generics: public interface Copyable { C copy(); } public class Example implements Copyable { ... @Override public Example copy() { return new Example(this); //invoke copy constructor } } Obviously this is not that elegant, both the headers of Copyable and Example look...