当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Extend generic interface without assigning type?

问题描述:

I'm trying to read Clojure source code.

There is a IFn interface whose declaration is like :

public interface IFn extends Callable, Runnable{

I think Callable is generic. How can IFn know what the type specified here?

Interface Callable<V>

网友答案:

It can't. That declaration is basically using the raw type, which is a bad idea. It would be much better to write:

public interface Function<V> extends Callable<V>, Runnable

That said - I hadn't noticed you were talking about Clojure rather than Java. Given that they're building a bridge between languages, they can do what they want with the type system, to some extent :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: