The method binarySearch(List<? extends Comparable<? super T>>, T) in the type Collections is not app
作者&投稿:满环 (若有异议请与网页底部的电邮联系)
我也是刚学这个没多久,不能保证我的说法完全正确。我的理解是
>代表任何实现了comparable接口的实例,且接口的类型是comparable。
>代表类型是T的实例,且这个T要实现comparable 接口,接口的类型是comparable
两者的区别大概是前者范围更广,可以是T 或其子类,甚至是只要实现了comparable接口的其他类(虽然觉得没啥卵用)。而后者,只能是T 。。
写个类,实现Comparable 接口就清楚了
class Student implements Comparable {
//////////
}
List<? extends Comparable<? super T>>
这个类型比较复杂,它首先要求你一个List对象,随后对这个List的泛型参数要求是:
? extends Comparable<? super T>
也就是一个实现了Comparable<? super T>接口的类T
然后来看你传入的参数是 List<Student>
所以Student类必须是一个 Comparable<? super Student> 的类,而你的Student类只实现了裸的Comparable,没有实现泛型版本的Comparable,所以参数不匹配
何晴五粒: The method binarySearch(List>, T) in the type Collections is not app这是因为binarySearch的第一个参数类型是:List>...
永济市13695022499: The method binarySearch(List<? extends Comparable<? super T>>, T) in the type Collections is not app - ?
何晴五粒: 这是因为binarySearch的第一个参数类型是: List<? extends Comparable<? super T>> 这个类型比较复杂,它首先要求你一个List对象,随后对这个List的泛型参数要求是: ? extends Comparable<? super T> 也就是一个实现了Comparable<? super T>接口的类T 然后来看你传入的参数是 List<Student> 所以Student类必须是一个 Comparable<? super Student> 的类,而你的Student类只实现了裸的Comparable,没有实现泛型版本的Comparable,所以参数不匹配
永济市13695022499: 语法问题: the method is proved effective. - ?
何晴五粒: effective在这里不是宾语,也不是补语,这是表语,是主系表结构.表语是说明主语的性质,状态,特征等,放于系动词之后. 这里的prove 是终止系动词. 系动词总共有六类: 1.状态系动词,只有be 动词一类 2.持续系动词,表示主...
永济市13695022499: ...的方法,用method表示,有哪几种说法? - ?
何晴五粒: the method of by....method
永济市13695022499: 请问jsp这种报错The method getparameter(String) is undefined for the type HttpServletRequest怎么改 - ?
何晴五粒: The method undefined for the type HttpServletRequest 就是你的方法没有写或者写错了 显然你是先错了,应该是getParameter( )
永济市13695022499: 后面两个“the method”可用什么词代替,以避免重复? - ?
何晴五粒: 不知道上文是什么,可以把method搬到前面半句里,比如: ...there are many methods, such as computing the variable based on LMS algorithm, estimating the variable based on an adaptive algorithm, and determining the variable using complex techniques.
永济市13695022499: java报错 代码红叉报“The method setOmittable(boolean) is undefined for the type ParameterDesc? - ?
何晴五粒: 把public boolean isOmittable(){ return this.omittable;}改为:public boolean Omittable(){ return thi...
永济市13695022499: java报错:The method checkForWarning(SQLWarning) is undefined for the type db - ?
何晴五粒: 在db 这个类中没有定义 checkForWarning(SQLWarning)这个方法 看看是不是字母大小写写错了 public Class Db{ public void checkForWarning(String SQLWarning){ //具体功能是什么不知道} }
永济市13695022499: java中the method parseDouble is undefine是什么意思?
何晴五粒: 正确写法 Double.parseDouble(""); 看下你用对了没 字面意义是说:parseDouble 方法未定义
永济市13695022499: 程序报错The method abbreviatedzoom(Image, int, int) in the type PictureTool is not applicable - ?
何晴五粒: 定义的参数类型和调用时的参数类型不符.定义的参数类型分别是:Image, int, int但调用时的参数类型是:String, int, int同时系统无法将String类型转换为Image类型.