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 Build a Simple Android App with Java Basic Android Programming Using the Random Class

Jack Gugolz
Jack Gugolz
280 Points

Build a Simple Android App with Java - RandomTest Challenge Task 4 of 4 help

"Create a String variable named intAsString. Convert the randomNumber integer to a String value and store it in the intAsString variable. Hint: Add them together like in the video!"

Cant figure out the answer to this statement. Need help to continue the course. Thanks

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(intAsString);

how

1 Answer

Hi there,

The last task requires you to create a new variable called intAsString of type String. Assign into that the result of adding an empty string to randomNumber.

Make sense?

Steve.

Jack Gugolz
Jack Gugolz
280 Points

I tried:

Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(intAsString);
String intAsString = randomnumber + "";

Did not work so what am I missing?

Don't put intAsString in your nextInt method. Pass in the number 10.

Jack Gugolz
Jack Gugolz
280 Points

Made the change:

Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomnumber + "";

Still some problem though

Your variable is called randomNumber not randomnumber. You typo'd the last line. :smile:

Jack Gugolz
Jack Gugolz
280 Points

There we go! Thank you dude :)

If you copy your code in and hit the Preview button, it'll show you where your syntax errors are. This one showed up in there. Might help you progress more quickly rather than waiting for a reply in here.

Glad you got going again! :+1: