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 trialBenjamin Swift
1,536 PointsChanging intAsString to a string value
Hi, In this code challenge I'm trying to change intAsString to a string variable, but I cannot figure out how to do it! Help! Thank you!
1 Answer
Dane Parchment
Treehouse Moderator 11,077 PointsAlright well seeing as you are at the last part of the code challenge I will assume your code looks like this:
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
Well next we need to convert the value of the randomNumber to a string. To do this we need to use the method toString.
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = Integer.toString(randomNumber);
That should be all and that should work. Good Luck!
Benjamin Swift
1,536 PointsBenjamin Swift
1,536 PointsGreat, thank you!