Can we represent “self class” in Java (or Kotlin)?
关注者
44被浏览
5,275登录后你可以
不限量看优质回答私信答主深度交流精彩内容一键收藏
工程上的作法基本上就是加个泛型参数了吧,比如说Java的Comparator:
public interface Comparable<T> { int compareTo(T o); }
public final class String implements Comparable<String> /* and something else */ { /* xxx */ }
但是感觉约束力还是不太够,不过很多都这么做的就是了。