日期:2014-05-20  浏览次数:20550 次

请各位大侠帮忙看一下啊,这到底是怎么回事
String   str= "asdfghjkl ";
int   num=0;
for   (int   i=0;i <str.length();i++)
    {    
          if(str.substring(i,i+1)== "s ")
{
    num=1;
    System.out.println(num);
}
  }
str字符串里明名是有s的,可是为什么IF语句不执行呢?

------解决方案--------------------
if(str.substring(i,i+1).equals( "s ")
...

if(str.charAt(i) == 's ')

if(str.indexOf( "s ") != -1)

if(str.indexOf( 's ') != -1)

if(str.contains( "s "))