返回列表 發帖
  1. public class C521 {
  2.     long s,e;
  3.         C521() throws Exception
  4.     {
  5.             s=System.currentTimeMillis();
  6.             test3();
  7.             e=System.currentTimeMillis();
  8.             System.out.println("花費:"+(e-s)+" 毫秒");
  9.            
  10.     }
  11.         void test1()
  12.         {
  13.                 for(int i=1;i<=10000;i++)
  14.                         System.out.println(i);
  15.         }
  16.         void test2()
  17.         {
  18.                 StringBuilder sb=new StringBuilder();
  19.                 for(int i=1;i<=10000;i++)
  20.                         sb.append(i+"\n");
  21.                 System.out.println(sb);
  22.         }
  23.         void test3()
  24.         {
  25.                 String str=" ";
  26.                 for(int i=1;i<=10000;i++)
  27.                         str+=i+"\n";
  28.                 System.out.println(str);
  29.         }
  30.     public static void main(String[] args) throws Exception{
  31.                 new C521();
  32.         }
  33. }
複製代碼

TOP

返回列表