Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Chanse Strode
Chanse Strode
22,345 Points

Learning the Language: Code Challenge: Objects and Random Numbers

Random randomGenerator = new Random();

int randomNumber = randomGenerator.nextInt(10);

intAsString = Integer.toString(randomNumber);

why is this not working?

3 Answers

Stone Preston
Stone Preston
42,016 Points

i dont know java but it looks like you are missing the data type for your string just from looking at your other code

Philip Larson
Philip Larson
7,553 Points

As Stone Preston said, it seems like you have missed to define the variable intAsString?

I think it should be:

    Random randomGenerator = new Random();

    int randomNumber = randomGenerator.nextInt(10);

    String intAsString = Integer.toString(randomNumber);
Chanse Strode
Chanse Strode
22,345 Points

Thank you very much! I was sleep deprived last night and looked over that like 20 times!