返回列表 發帖

split() 函式

  1. public class ch67
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         String str1="Hello! My name is Tony!";
  6.         String a[]=str1.split("e");
  7.         for(int i=0; i<a.length; i++)
  8.         {
  9.             System.out.println(a[i]);
  10.         }
  11.         String str2="星星:月亮:太陽";
  12.         String b[]=str2.split(":");
  13.         for(int i=0; i<b.length; i++)
  14.         {
  15.             System.out.println(b[i]);
  16.         }
  17.     }
  18. }
複製代碼

返回列表