jimphei學(xué)習(xí)工作室

          jimphei學(xué)習(xí)工作室

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            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 閱讀(85) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 鸡东县| 囊谦县| 彭阳县| 兰考县| 霞浦县| 来凤县| 丽水市| 商都县| 夏邑县| 泸定县| 微博| 南京市| 东乡县| 蒙城县| 洛阳市| 泗洪县| 许昌县| 东源县| 十堰市| 新余市| 秦皇岛市| 离岛区| 桐柏县| 武邑县| 瓦房店市| 枣强县| 高陵县| 鱼台县| 泗阳县| 成都市| 乐清市| 茶陵县| 阿克苏市| 台江县| 太和县| 普格县| 兴化市| 菏泽市| 神农架林区| 郑州市| 萍乡市|