dej*_*jay 1 java generics integer comparable
我正在为AP计算机科学考试做准备,我对文本对Integer课程的讨论感到困惑.
文本定义Integer的compareTo,如下所示:
int compareTo(Object other)
Run Code Online (Sandbox Code Playgroud)
从一开始我就知道它会有一个Object参数,因为我认为这是它可以实现的唯一方法Comparable.但是,我最终查看了IntegerEclipse 中的类,我发现它使用了泛型Comparable,因此compareTo使用Integer参数定义.
这是我书中的错误吗?这使我相信,这是铸造Object成Integer的方法,这是错误的(并就考试的差别).我在这里错过了什么吗?