这是毕老师讲的一道题目,我做了个实验,8<<1比2<<3快了很多
import java.util.*;
public class ListDemo {
public static void main(String[] args)
{
int i = 2;
int j = 8;
long a;
long b;
long c;
long d;
a = System.nanoTime();
System.out.println(i<<3);
b = System.nanoTime();
System.out.println(b-a);
c = System.nanoTime();
System.out.println(j<<1);
d = System.nanoTime();
System.out.println(d-c);
}
}
<<<<<<<<<<<<<<<<<<
16
311045
16
24961
|