package shark.zd.数组操作;
public class Array { String[] url={"www.",".com"}; public boolean IsUrl(String Spara){ for(int i=0;i<url.length;i++) { if(Spara.indexOf(url[i])==-1) return false; } return true; } public static void main(String[] agres){ Array myarray = new Array(); boolean burl = myarray.IsUrl(""); System.out.println("1"+"网址is"+burl); burl = myarray.IsUrl("wwwkjaosdf.com"); System.out.println("2"+"网址is"+burl); }
} package shark.zd.数组操作;
import com.sun.org.apache.bcel.internal.generic.RETURN;
public class ArrayNum { char[] cNum = {'1','2','3','4','5','6','7','8','9','0'}; public boolean IsNum(String sPara){ for(int i=0;i<sPara.length();i++){ char cTemp = sPara.charAt(i); boolean bTemp = false; for(int j=0;j<cNum.length;j++){ if(cTemp==cNum[j]) {bTemp = true; break; } } if(!bTemp) return false; } return true; } public static void main(String[] arges){ ArrayNum bNum =new ArrayNum(); boolean bIsNum = bNum.IsNum("1234"); System.out.println(bIsNum); bIsNum = bNum.IsNum("123s546"); System.out.println(bIsNum); } } package shark.zd.数组操作;
public class ArrayStr { char[] cStr={'a','b','c','d','e','f','g','h', 'i','j','k','l','m','n','o','p', 'q','r','s','t','u','v','w','x','y','z'}; public boolean IsStr(String sPara){ for(int i=0;i<sPara.length();i++){ char cTemp = sPara.charAt(i); boolean bTemp =false; for(int j=0;j<cStr.length;j++){ if(cTemp==cStr[j]){ bTemp=true; break; } } if(!bTemp) return false; } return true; } public static void main(String[] arges){ ArrayStr mNum=new ArrayStr(); boolean bIsNum = mNum.IsStr("adf"); System.out.println("bIsNum is "+bIsNum); bIsNum =mNum.IsStr("adf4s"); System.out.println("bIsNum is "+bIsNum); }
}
|