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 trialJack Gugolz
280 PointsBuild 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
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(intAsString);
1 Answer
Steve Hunter
57,712 PointsHi 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
280 PointsI tried:
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(intAsString);
String intAsString = randomnumber + "";
Did not work so what am I missing?
Steve Hunter
57,712 PointsDon't put intAsString
in your nextInt
method. Pass in the number 10.
Jack Gugolz
280 PointsMade the change:
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomnumber + "";
Still some problem though
Steve Hunter
57,712 PointsYour variable is called randomNumber
not randomnumber
. You typo'd the last line.
Jack Gugolz
280 PointsThere we go! Thank you dude :)
Steve Hunter
57,712 PointsIf 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!
Munashe Shava
6,789 PointsMunashe Shava
6,789 Pointshow