Pra*_*eek 6 java generics collections interface marker-interfaces
在练习反思的同时,我SelfComparable Interface在Collections课堂上了解了一下
interface java.util.Collections$SelfComparable
Run Code Online (Sandbox Code Playgroud)
这个界面用于什么?
它没有做任何事情.它是私有的,因此您无法导入它.
这是一个注释,该类型是"SelfComparable",并没有实际使用.
没有实现此接口.使用它的代码依赖于它将在运行时被丢弃的事实.
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
return (T)max((Collection<SelfComparable>) (Collection) coll);
Run Code Online (Sandbox Code Playgroud)
可能是
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
return (T)max(/*SelfComparable*/ (Collection) coll);
Run Code Online (Sandbox Code Playgroud)
因为它会在运行时被忽略.
| 归档时间: |
|
| 查看次数: |
321 次 |
| 最近记录: |