[Solved] Generate a random integer within a given range AND is even ONLY [closed]
If you wanted to be clever, you could make sure the least significant bit of the number is not set: int num = (new Random().nextInt(199) & ~1) + 2; This will ensure that the number is always even. Thanks Eyal Shneider and Omaha Marcelo‘s comment from the OP is the correct answer, though. Get a … Read more