哪有函数手册?可以看到原型吗? 是不是要看java documents?thanks and best regards; myworkhs
恩恩, 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.
thanks, you are welcome and your english is so good!best regards; myworkhs
I want to know how to use the documents effectually?myworkhs thanks
是不是要看java documents?thanks and best regards;
myworkhs
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.
myworkhs
thanks
可以下JDK的文档,indexOf(char)就是看String 里有没有char,没有就返回-1,你上面那段就是看string是不是E-Mail地址
多看看原代码就可以了!
哈哈将来如果你从事j2ee的话,你就多看看java.lang java.util 这些都是基础
http://java.sun.com/j2se/1.5.0/docs/api/
下载的地址,下载里面的 J2SE 5.0 Documentation
http://java.sun.com/j2se/1.5.0/download.jsp
* 函数名称: 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;
}