查看程序运行多少时间

1 long time1 = System.currentTimeMillis();
2 
3 // 代码块
4 
5 long time2 = System.currentTimeMillis();
6 
7 int time = (int) ((time2 - time1)/1000);
8 
9 System.out.println("执行了22:"+time+"秒!");

 

posted @ 2019-07-02 16:07  彭卫强  阅读(400)  评论(0)    收藏  举报
本文原创,文中若有表述不清或存在问题,欢迎指正。共同学习