jimphei学习工作室

jimphei学习工作室

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  23 随笔 :: 0 文章 :: 1 评论 :: 0 Trackbacks

 

public static void test1(){
        String s
="AaaaABBBBcc&^%adfsfdCCOOkk99876 _haHA";
        
int lCount=0,uCount=0,oCount=0,nCount=0;
        
for(int i=0;i<s.length();i++)
        
{
            
char c=s.charAt(i);
//            if(c>='a'&&c<='z')
//            {
//                lCount++;
//            }else if(c>='A'&&c<='Z')
//            {
//                uCount++;
//            }
//            else
//            {
//                oCount++;
//            }
            if(Character.isLowerCase(c))
            
{
                lCount
++;
            }
else if(Character.isUpperCase(c))
            
{
                uCount
++;
            }

            
else if(Character.isDigit(c))
            
{
                nCount
++;
            }
else
            
{
                oCount
++;
            }

                 
        }

        System.out.println(lCount
+"  "+uCount+"  "+nCount+"  "+oCount);
    }

    
public static void test2(){
        
int count=0,index=-1;
        String s 
= "sunjavahpjavaokjavajjavahahajavajavagoodjava";
        String sFind
="java";
        
while((index=s.indexOf(sFind))!=-1)
        
{
            s
=s.substring(index+sFind.length());
            count
++;
        }

        System.out.println(count);

    }
posted on 2009-03-23 16:08 jimphei 阅读(79) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: