返回列表 發帖

TQC203 - 拆解字串

本帖最後由 tonyh 於 2013-6-8 16:25 編輯
  1. public class tqc203
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         if(args.length==1)
  6.         {
  7.             String str[]=args[0].split(",");
  8.             System.out.println("逗號隔開的字串個數共有: "+str.length);
  9.             for(int i=0; i<str.length; i++)
  10.             {
  11.                  System.out.println((i+1)+"."+str[i]);
  12.             }
  13.         }else
  14.         {
  15.             System.out.println("參數錯誤!字串不得有空白或必須以逗號隔開!");
  16.         }
  17.     }
  18. }
複製代碼

返回列表