ResultSet rs = null;String str1 = request.getParameter( "test" );
String str2 = rs.getInt( "test" ) + "";// str1,str2值相等
if( str1.equals( str2 ) )
{
}
if( str1.compareTo( str2 ) == 0 )
{
}为什么以上两个if语句都不能执行阿???
String str2 = rs.getInt( "test" ) + "";// str1,str2值相等
if( str1.equals( str2 ) )
{
}
if( str1.compareTo( str2 ) == 0 )
{
}为什么以上两个if语句都不能执行阿???
compareTo()是两个串对象比较大小,返回一个整数值,如果调用串对象大,返回正整数,反之,返回负整数。相等则返回。返回的值是两个串首次出现不同字符的ASCII的差值。
int i = rs.getInt( "test" );
String str2 = i + "";// str1,str2值相等
if( str1.equals( str2 ) )
{
System.out.println( "11111" );
}
if( str1.compareTo( str2 ) == 0 )
{
System.out.println( "22222" );
}为什么以上两个if语句条件都不满足阿???