Created
January 30, 2020 08:57
-
-
Save Dupleks/561f6488d7d08ea7a2a86554c93cb0c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Solution { | |
public static void main(String[] args) { | |
System.out.println(getRandomNumberInRange(0,185)); | |
System.out.println(getRandomNumberInRange(0,185)); | |
System.out.println(getRandomNumberInRange(0,185)); | |
System.out.println(getRandomNumberInRange(0,185)); | |
System.out.println(getRandomNumberInRange(0,185)); | |
System.out.println(getRandomNumberInRange(0,185)); | |
} | |
private static int getRandomNumberInRange(int min, int max) { | |
if (min >= max) { | |
throw new IllegalArgumentException("max must be greater than min"); | |
} | |
Random r = new Random(); | |
return r.nextInt((max - min) + 1) + min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment