日期:2014-05-20 浏览次数:20706 次
String a = "abc";
Integer b = 1;
String c = null;
long begin = System.nanoTime();
for(int i = 0; i < 1000; i ++){
c = a + b;
}
System.out.println(System.nanoTime() - begin);
String a = "abc";
int b = 1;
String c = null;
long begin = System.nanoTime();
for(int i = 0; i < 1000; i ++){
c = a + b;
}
System.out.println(System.nanoTime() - begin);
public class Test1 {
public static void main(String[] args) {
Integer b = 1;
long begin = System.nanoTime();
System.out.println(b);
System.out.println(System.nanoTime() - begin);
}
}
public class Test2 {
public static void main(String[] args) {
int b = 1;
long begin = System.nanoTime();
System.out.println(""+b);
System.out.println(System.nanoTime() - begin);
}
}
volatile int i ;
public void haha(){
String a = "abc";
Integer b = 1;
String c = null;
long begin = System.nanoTime();
for( i = 0 ; i < 1000; i ++){
c = a + b;
}
System.out.println(System.nanoTime() - begin);
System.out.println(c);
}