氟塑料離心泵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

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          技術網站

          行業網站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          站長網 氟塑料離心泵 注塑機 液晶廣告機
          主站蜘蛛池模板: 辽阳县| 腾冲县| 内乡县| 托克逊县| 长白| 长沙县| 祁连县| 招远市| 宾阳县| 景谷| 肇州县| 罗山县| 于都县| 江永县| 兴国县| 上饶县| 那坡县| 青岛市| 海门市| 金平| 祥云县| 天门市| 东海县| 渭源县| 商丘市| 阿巴嘎旗| 延长县| 巴林左旗| 开远市| 黄浦区| 安顺市| 商城县| 壤塘县| 涿州市| 上思县| 阿勒泰市| 祁门县| 枝江市| 仁寿县| 施甸县| 贵州省|