- package ch02;
- public class ch02 {
- long a,b,c,d,e,f;
-
-
- ch02()
- {
- a=System.currentTimeMillis();
- test1();
- b=System.currentTimeMillis();
- System.out.println("共花費"+(b-a)+"毫秒");
-
- }
- void test1()
- {
- for(int i=1;i<=10000;i++)
- System.out.println(i);
-
- }
- void test2()
- {
- StringBuilder sb=new StringBuilder();
- for(int i=1;i<=10000;i++)
- sb.append(i+"\n");
- System.out.println(sb);
- }
- void test3()
- {
- String str="";
- for(int i=1;i<=10000;i++)
- str=str+i+"\n";
- System.out.println(str);
- }
- public static void main(String[] args){
- new ch02();
- }
- }
複製代碼 |