indexOf(char c) 是String 类的函数
作用是 返回字符串中字符c 的位置,如果没有, 就返回 -1.在你的程序中, 它的作用是判断用户输入的email 中有没有  @ 字符, 从而确定输入的是不是正确的email 地址格式

解决方案 »

  1.   

    哪有函数手册?可以看到原型吗?
    是不是要看java documents?thanks and best regards;
    myworkhs
      

  2.   

    恩恩, documents 就是最好的函数手册
    indexOf
    public int indexOf(int ch)
    Returns the index within this string of the first occurrence of the specified character. If a character with value ch occurs in the character sequence represented by this String object, then the index of the first such occurrence is returned -- that is, the smallest value k such that: 
     this.charAt(k) == ch
     is true. If no such character occurs in this string, then -1 is returned. Parameters:
    ch - a character. 
    Returns:
    the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
      

  3.   

    thanks, you are welcome and your english is so good!best regards;
    myworkhs
      

  4.   

    I want to know how to use the documents effectually?myworkhs
    thanks
      

  5.   

    http://192.18.97.107/ECom/EComTicketServlet/BEGIND61133351016AB4DD88583847B96F924/-2147483648/778857447/1/531806/531794/778857447/2ts+/westCoastFSEND/jdk-1.5.0-doc-oth-JPR/jdk-1.5.0-doc-oth-JPR:1/jdk-1_5_0-doc.zip
    可以下JDK的文档,indexOf(char)就是看String 里有没有char,没有就返回-1,你上面那段就是看string是不是E-Mail地址
      

  6.   

    indexOf是你所查找字符或字符串的位置
      

  7.   

    是啊!要想学好java,jdk的帮助文挡是你最好的学习资料!
    多看看原代码就可以了!
    哈哈将来如果你从事j2ee的话,你就多看看java.lang   java.util  这些都是基础
      

  8.   

    在线查找的地址 
    http://java.sun.com/j2se/1.5.0/docs/api/
    下载的地址,下载里面的  J2SE 5.0 Documentation
    http://java.sun.com/j2se/1.5.0/download.jsp
      

  9.   

    /*****************************************************<BR>
      * 函数名称: IsEmail                             <BR>
      * 机能概要: Email格式判断         <BR>
      *                                                     <BR>
      * 参数: strin待判断的字符串             <BR>
      * 返回值: True:正确                           <BR>
      * False:错误                 <BR>
      *********************************************************/
       public static boolean IsEmail(String strin){     int nPos;
         String strTemp;
         String strLeft, strRight;
         boolean bFlag = true;/*     //敿妏偺僠僃僢僋
         if (!IsHalfWidth(strin)) return false;*/
         //@符号判断
         if (strin.indexOf ("@") == -1) return false;
         if (strin.indexOf ("@") != strin.lastIndexOf ("@")) return false;     strTemp = strin.replace ('@','1');
         strTemp = strTemp.replace ('.','1');
         strTemp = strTemp.replace ('-','1');
         strTemp = strTemp.replace ('_','1');
         //if (!IsHalfEnglishAndNum(strTemp)) return false;     nPos = strin.indexOf ("@");
         strLeft  = strin.substring (0,nPos);
         strRight = strin.substring (nPos + 1);     if (strLeft.indexOf (".") != -1) return false;
         if (strLeft.length () < 3) return false;     if (strRight.indexOf (".") == -1) return false;
         if ((strRight.indexOf (".") == 0) ||
             (strRight.lastIndexOf (".") == strRight.length () - 1)) return false;     nPos = strin.lastIndexOf (".");
         strTemp = strin.substring (nPos + 1);
    //     if (IsHalfNum(strTemp)) return false;     strTemp = strRight;
         nPos = strTemp.indexOf (".");
         while (bFlag){
           strTemp = strTemp.substring (nPos + 1);
           nPos = strTemp.indexOf (".");
           if (nPos == 0) return false;
           if (nPos == -1) bFlag = false;
         }     return true;
      }