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);

1 Answer

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 57,546 Points

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?

Steve Hunter
Steve Hunter
Treehouse Moderator 57,546 Points

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

Steve Hunter
Steve Hunter
Treehouse Moderator 57,546 Points

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 :)

Steve Hunter
Steve Hunter
Treehouse Moderator 57,546 Points

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: