Skip to content

Commit 10d5ccb

Browse files
Update LearnMath.java
1 parent ed9a741 commit 10d5ccb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/basics2/LearnMath.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ public static void main(String[] args) {
55
System.out.println(getRandom(10, 20));
66
}
77

8-
public static int getRandom(int a, int b) {
9-
return (int) (Math.random() * (b - a + 1) + a);
8+
public static int getRandom(int l, int r) {
9+
return l + (int)(Math.random() * (r - l + 1));
1010
}
1111
}
12+
13+
// Math.random() -> 0.0 ≤ value < 1.0

0 commit comments

Comments
 (0)