- package lol;
- public class Main {
- long s,e;
- Main()
- {
- s=System.currentTimeMillis();
- test1();
- test2();
- test3();
- e=System.currentTimeMillis();
- System.out.println("花費: "+(e-s)+" 毫秒");
- }
-
- void test1()
- {
- for(int i=1;i<=10000;i++)
- {
- System.out.println(i);
- }
- System.out.println();
- }
- void test2()
- {
- StringBuilder sb=new StringBuilder();
- for(int i=1;i<=10000;i++)
- sb.append(i+"\n");
- System.out.println();
- }
- void test3()
- {
- String n="";
- for(int i=1;i<=10000;i++)
- n+=i+"\n";
- System.out.println();
- }
- public static void main(String[] args) throws Exception{
- new Main();
- }
- }
複製代碼 |