Advertisement
Guest User

Untitled

a guest
Jan 17th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. class Stopwatch{
  2.  
  3.     private long time=0;
  4.  
  5.     public void Start(){
  6.  
  7.         if (time==0){
  8.             this.time = System.nanoTime();
  9.         }
  10.     }
  11.  
  12.     public void Stop(){
  13.         long currentTime=System.nanoTime();
  14.         System.out.println(currentTime-this.time);
  15. //        System.out.println(this.time);
  16. //        System.out.println(currentTime);
  17.         this.time=0;
  18.     }
  19. }
  20.  
  21.  
  22.  
  23. public class Main {
  24.  
  25.  
  26.     public static void main(String[] args) {
  27.         // write your code here
  28.  
  29. Stopwatch stoperica = new Stopwatch();
  30.  
  31. stoperica.Start();
  32.  
  33.  
  34.  
  35. stoperica.Stop();
  36.  
  37.  
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement