teknoraver

unreachable

Nov 12th, 2021 (edited)
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. class rnd {
  2.     public static double rnd1() {
  3.         double d;
  4.         while (true) {
  5.             d = Math.random();
  6.             if (d < 0.01)
  7.                 return d;
  8.         };
  9.     }
  10.  
  11.     public static double rnd2() {
  12.         double d;
  13.         while (true) {
  14.             d = Math.random();
  15.             if (d < 0.01)
  16.                 break;
  17.         };
  18.         return d;
  19.     }
  20. }
  21.  
  22. /*
  23. $ javac Solution.java
  24. test.java:8: error: unreachable statement
  25.                 };
  26.                  ^
  27. 1 error
  28. /*
Add Comment
Please, Sign In to add comment