Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stopwatch{
- private long time=0;
- public void Start(){
- if (time==0){
- this.time = System.nanoTime();
- }
- }
- public void Stop(){
- long currentTime=System.nanoTime();
- System.out.println(currentTime-this.time);
- // System.out.println(this.time);
- // System.out.println(currentTime);
- this.time=0;
- }
- }
- public class Main {
- public static void main(String[] args) {
- // write your code here
- Stopwatch stoperica = new Stopwatch();
- stoperica.Start();
- stoperica.Stop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement