Skip to content

Commit 35cb82f

Browse files
committed
Add link to explain randInt method in RandomNumbers instructions
1 parent 911e9bb commit 35cb82f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/com/codefortomorrow/intermediate/chapter10/practice/RandomNumbers.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ To call the method, type randInt(7, 77) and assign it to
1818
and min to Integer.MAX_VALUE when you first initialize them.
1919
This ensures that when you iterate through the
2020
randomly generated numbers in your array, the max and min
21-
are updated correctly.
22-
(You can also set max to 6 and min to 78.)
21+
are updated correctly. (You can also set max to 6 and min to 78.)
22+
23+
Note: Interested in seeing how the randInt() method works? You can read
24+
this Stack Overflow response: https://bit.ly/38IkeY2
2325
*/
2426

2527
public class RandomNumbers {
@@ -33,8 +35,7 @@ public static void main(String[] args) {
3335
* in the range [min, max]
3436
* @param min minimum random integer
3537
* @param max maximum random integer
36-
* @return a random integer in the range
37-
* [min, max]
38+
* @return a random integer in the range [min, max]
3839
*/
3940
public static int randInt(int min, int max) {
4041
return min + (int) (Math.random() * ((max - min) + 1));

src/com/codefortomorrow/intermediate/chapter10/solutions/RandomNumbers.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ To call the method, type randInt(7, 77) and assign it to
1818
and min to Integer.MAX_VALUE when you first initialize them.
1919
This ensures that when you iterate through the
2020
randomly generated numbers in your array, the max and min
21-
are updated correctly.
22-
(You can also set max to 6 and min to 78.)
21+
are updated correctly. (You can also set max to 6 and min to 78.)
22+
23+
Note: Interested in seeing how the randInt() method works? You can read
24+
this Stack Overflow response: https://bit.ly/38IkeY2
2325
*/
2426

2527
public class RandomNumbers {
@@ -67,8 +69,7 @@ public static void main(String[] args) {
6769
* in the range [min, max]
6870
* @param min minimum random integer
6971
* @param max maximum random integer
70-
* @return a random integer in the range
71-
* [min, max]
72+
* @return a random integer in the range [min, max]
7273
*/
7374
public static int randInt(int min, int max) {
7475
return min + (int) (Math.random() * ((max - min) + 1));

0 commit comments

Comments
 (0)