Android Build a Simple Android App with Java Basic Android Programming Using the Random Class

Henry Hayden
Henry Hayden
7,572 Points

Is question three broken?

This is my answer: int randomNumber = randomGenerator.nextInt( n: 9 ); I'm 99% certain that my answer is correct as this is just asking us to repeat what was just explained in the video. The actual parameter name for nextInt is 'bound' not 'n' like in the video, but it says that there's a compiler error and that my syntax is incorrect regardless of whether I use 'n' or 'bound'. Not sure if the question is broken or I'm just derping out, please help me get to the correct answer or fix the question if it turns out to be broken.
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(n:9);

2 Answers

Steven Parker
Steven Parker
170,315 Points

Since the instructions say to "Use the version of nextInt() that takes a parameter specifying how many numbers to choose from", you only need to provide that quantity value as the argument.

And since the target range is "from 0 to 9", the quantity should be 10.