当前位置: 技术问答>java相关
String的compareTo(str) 的异常
来源: 互联网 发布时间:2015-05-02
本文导语: 当把一个int数作为参数时,肯定是编译不过,不用说了。但是 当我把一个字符数组作为参数比较时,编译期通过,但是运行期错误。 这是不是一个bug,为什么允许字符数组编译通过,明明参数类型不匹配。 | ...
当把一个int数作为参数时,肯定是编译不过,不用说了。但是
当我把一个字符数组作为参数比较时,编译期通过,但是运行期错误。
这是不是一个bug,为什么允许字符数组编译通过,明明参数类型不匹配。
|
int compareTo(Object o)
Compares this String to another Object.
int compareTo(String anotherString)
Compares two strings lexicographically.
int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations.
懒得说话了, 自己看吧.
Compares this String to another Object.
int compareTo(String anotherString)
Compares two strings lexicographically.
int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations.
懒得说话了, 自己看吧.
|
To lyhook(问题人物)
你看看jdk.compareTo的参数有String,也有Object
int compareTo(Object o)
Compares this String to another Object.
int compareTo(String anotherString)
Compares two strings lexicographically.
int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations.
你看看jdk.compareTo的参数有String,也有Object
int compareTo(Object o)
Compares this String to another Object.
int compareTo(String anotherString)
Compares two strings lexicographically.
int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations.