Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Exercise6_13 {
- public static void main(String[] args) {
- int random = Exercise6_13.getRandom(34, 35);
- System.out.println(random);
- }
- public static int getRandom(int... numbers) {
- int randomNumber;
- while (true) {
- boolean match = false;
- randomNumber = (int) (Math.random() * 53 + 1);
- for (int i : numbers) {
- if (i == randomNumber) {
- match = true;
- break;
- }
- }
- if (!match) {
- return randomNumber;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement