JAVA 測試 String物件時間
ref: http://www.javaworld.com.tw/jute/post/view?bid=29&id=9557
public class Test{
public static void main(String[] args){
new Test();
}
public Test(){
System.out.println(”normal converting (ms): ” + normal());
System.out.println(”algorithm converting (ms): ” + algo());
}
public long normal(){
int a = 0;
String b = null;
long st = System.currentTimeMillis();
for (int i = 0; i < 2000000; i++){
b = a + “”;
}
long et = System.currentTimeMillis();
return (et – st);
}
public long algo(){
int a = 0;
String b [...]