文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>数组操作

数组操作

时间:2010-12-04  来源:zhengdong1987

判断特定格式  

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("www.baidu.com");
        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);
        
    }

}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载