1.怎样在Eclipse中计算程序所耗费的时间:
long startTime=System.currentTimeMillis(); //获取开始时间
while(true){ //测试的代码段 long endTime=System.currentTimeMillis(); //获取结束时间 try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("程序运行时间: "+(endTime-startTime)/1000+"s");