比较结果!!!!!!!!!!!

sam_xcx 2002-03-29 09:34:20
class x13
{
public static void main(String[] args)
{
int n3="JAVELine".compareToIgnoreCase("javelinek");
System.out.println((int)'k');
System.out.println(n3);

}
}

请不要在机器上运行该程序,请问n3的值是多少??
若换成
int n3="JAVE".compareToIgnoreCase("javeline");

n3又是多少,有规律吗??
...全文
48 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
idpmud 2002-03-29
  • 打赏
  • 举报
回复
n3的值应该是-1,如果你变换字符的长度的话,应该以字符长度差作为返回值,另外强制类型转换,返回的是10进制的数值。
snowredfox 2002-03-29
  • 打赏
  • 举报
回复
0完全相同,其它则不同
ctrlpower 2002-03-29
  • 打赏
  • 举报
回复
public int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations. This method returns an integer whose sign is that of this.toUpperCase().toLowerCase().compareTo( str.toUpperCase().toLowerCase()).
Note that this method does not take locale into account, and will result in an unsatisfactory ordering for certain locales. The java.text package provides collators to allow locale-sensitive ordering.

Parameters:
str - the String to be compared.
Returns:
a negative integer, zero, or a positive integer as the the specified String is greater than, equal to, or less than this String, ignoring case considerations

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧