氟塑料離心泵www.buybeng.com

          jquery教程http://www.software8.co/wzjs/jquery/

          StringBuffer的常用方法

          1. //通過append()方法連接各種類型的數據  
          2. /*public class Append{ 
          3.     public static void main(String []args){ 
          4.         StringBuffer buf = new StringBuffer(); 
          5.         buf.append("Hello \n"); 
          6.         buf.append("Hello ").append("World!\n"); 
          7.         buf.append("數字:").append(1).append("\n");//代碼鏈 
          8.         buf.append("布爾:").append(true); 
          9.         System.out.println(buf); 
          10.     } 
          11. }*/  
          12. /*public class Append{ 
          13.     public static void main(String []args){ 
          14.         StringBuffer buf = new StringBuffer(); 
          15.         buf.append("Hello "); 
          16.         fun(buf); 
          17.         System.out.println(buf); 
          18.     } 
          19.     public static void fun(StringBuffer s){ 
          20.         s.append("MLDN ").append("LiXingHua"); 
          21.     } 
          22. }*/  
          23. //Hello MLDN LiXingHua  
          24.   
          25. //直接使用insert()方法在指定位置上為StringBuffer添加內容  
          26. /*public class Append{ 
          27.     public static void main(String []args){ 
          28.         StringBuffer buf = new StringBuffer(); 
          29.         buf.append("Hello!!!"); 
          30.         buf.insert(0,"Hello "); 
          31.         System.out.println(buf); 
          32.         buf.insert(buf.length()," MLDN~~"); 
          33.         System.out.println(buf); 
          34.     } 
          35. }*/  
          36.   
          37. //字符串反轉操作--reverse  
          38. /*public class Append{ 
          39.     public static void main(String []args){ 
          40.         StringBuffer buf = new StringBuffer(); 
          41.         buf.append("World!!!"); 
          42.         buf.insert(0,"Hello "); 
          43.         String str = buf.reverse().toString(); 
          44.         System.out.println(str); 
          45.     } 
          46. }*/  
          47.   
          48. //替換指定范圍的內容--replace  
          49. /*public class Append{ 
          50.     public static void main(String []args){ 
          51.         StringBuffer buf = new StringBuffer(); 
          52.         buf.append("Hello ").append("World!!"); 
          53.         buf.replace(6,11,"LiXiHua"); 
          54.         System.out.println(buf); 
          55.     } 
          56. }*/  
          57.   
          58. //字符串截取--substring  
          59. /*public class Append{ 
          60.     public static void main(String []args){ 
          61.         StringBuffer buf = new StringBuffer(); 
          62.         buf.append("Hello ").append("World!!"); 
          63.         buf.replace(6,11,"LiXiHua"); 
          64.         String str = buf.substring(6,15); 
          65.         System.out.println(str); 
          66.     } 
          67. }*/  
          68.   
          69. //刪除指定范圍的字符串--delete  
          70. /*public class Append{ 
          71.     public static void main(String []args){ 
          72.         StringBuffer buf = new StringBuffer(); 
          73.         buf.append("Hello ").append("World!!"); 
          74.         buf.replace(6,11,"LiXiHua"); 
          75.         String str = buf.delete(6,15).toString(); 
          76.         System.out.println(str); 
          77.     } 
          78. }*/  
          79.   
          80. //查找指定的內容是否存在--indexOf  
          81. public class Append{  
          82.     public static void main(String []args){  
          83.         StringBuffer buf = new StringBuffer();  
          84.         buf.append("Hello ").append("World!!");  
          85.         if(buf.indexOf("Hello")==-1){  
          86.             System.out.println("沒有找到指定內容");  
          87.         }else{  
          88.             System.out.println("可以找到指定內容");  
          89.         }  
          90.     }  
          91. }  

          posted on 2012-10-22 09:56 你爸是李剛 閱讀(158) 評論(0)  編輯  收藏


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


          網站導航:
           
          <2012年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          技術網站

          行業網站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          站長網 氟塑料離心泵 注塑機 液晶廣告機
          主站蜘蛛池模板: 瑞安市| 柳林县| 华容县| 通道| 黔江区| 樟树市| 尤溪县| 高清| 沭阳县| 循化| 宁德市| 健康| 共和县| 吉林省| 马边| 临安市| 囊谦县| 涞源县| 金乡县| 曲靖市| 清涧县| 新晃| 安新县| 礼泉县| 西安市| 珠海市| 色达县| 临泉县| 无为县| 高雄市| 广西| 祁阳县| 宝应县| 探索| 尼玛县| 东辽县| 会理县| 高碑店市| 太白县| 车险| 肥西县|