asked 185k views
4 votes
What is the possible output from system.out.println((int)math.random() * 4)?

asked
User Torra
by
8.1k points

1 Answer

4 votes
int randomWithRange(int min, int max) {
int range = (max - min) + 1;
return (int)(Math.random() * range);
}Output of randomWithRange(2, 5) 5 times:3 0 1 1 0

No related questions found