Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(n:9);

2 Answers

Steven Parker
Steven Parker
211,088 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.