用一个js的functionfunction haveDot(str) {
if (str == null){
return false;
} else {
var strlen = str.length;
var i = 0;
for (i = 0;i < strlen;i++) {
if (str.substring(i,i+1) != ".") continue;
return true;
}
}
return false;
}
if (str == null){
return false;
} else {
var strlen = str.length;
var i = 0;
for (i = 0;i < strlen;i++) {
if (str.substring(i,i+1) != ".") continue;
return true;
}
}
return false;
}
public int indexOf(String str)Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that:
this.startsWith(str, k)
is true. Parameters:
str - any string.
Returns:
if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.
public static void main(String args[]){
String temp="fdfdsf.fdfd.dfsdfsd.";
if(temp.indexOf('.')==-1){
System.out.println("字符串没有\".\"");
}
}
}