返回列表 發帖
  1. package ch02;


  2. public class ch02 {
  3.         long a,b,c,d,e,f;
  4.        
  5.        
  6.         ch02()
  7.         {
  8.                 a=System.currentTimeMillis();
  9.                 test1();
  10.                 b=System.currentTimeMillis();
  11.                 System.out.println("共花費"+(b-a)+"毫秒");
  12.                
  13.         }
  14.         void test1()
  15.         {
  16.                 for(int i=1;i<=10000;i++)
  17.                         System.out.println(i);
  18.                
  19.         }
  20.         void test2()
  21.         {
  22.                 StringBuilder sb=new StringBuilder();
  23.                 for(int i=1;i<=10000;i++)
  24.                         sb.append(i+"\n");
  25.                 System.out.println(sb);
  26.         }
  27.         void test3()
  28.         {
  29.                 String str="";
  30.                 for(int i=1;i<=10000;i++)
  31.                         str=str+i+"\n";
  32.                 System.out.println(str);
  33.         }
  34.         public static void main(String[] args){
  35.                 new ch02();

  36.         }

  37. }
複製代碼

TOP

返回列表