if (s.equals("aaa") || s.equals("bbb") || s.equals("ccc")){
 return true;
}else{
 return false;
}

解决方案 »

  1.   

    不对啊,我的String不是常量,是变量啊
      

  2.   

    mymoto(向下一步艰难迈进) 是正确的!
    为什么不试试先!
      

  3.   

    public boolean method(String s)
      {
        boolean ret = false;
        String strTest = "aaa,bbb,ccc,ddd,";
        
        int nBeginIndex = 0;
        int nEndIndex = 0;
        nEndIndex = strTest.indexOf(",",nBeginIndex);
        while(nEndIndex>0)
        {
          if((strTest.substring(nBeginIndex,nEndIndex)).equals(s))
          {
            ret = true;
            break;
          }
          else
          {
            nBeginIndex = nEndIndex + 1;
            nEndIndex = strTest.indexOf(",",nBeginIndex);
          }
        }
        
        return ret;
      }