在编码时候,有时候要比较不同方案的性能,就需要比较她们运行的时间。
计算代码运行时间的方法:
long start=System.currentTimeMillis();
.....//你的代码
long end =System.currentTimeMillis();
System.out.println(end-start);//单位为毫秒
在编码时候,有时候要比较不同方案的性能,就需要比较她们运行的时间。
计算代码运行时间的方法:
long start=System.currentTimeMillis();
.....//你的代码
long end =System.currentTimeMillis();
System.out.println(end-start);//单位为毫秒