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
fredrik bäcke
Courses Plus Student 270 PointsObjects and Randoms numbers challenge task 4/4
Challenge: "Declare a String variable named intAsString. Convert the randomNumber integer to a String value and store it in the intAsString variable. Hint: Use the toString() method of the Integer class."
My code:
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String = intAsString;
Interger.toString(intAsString);
I've tried numerous solutions and nothing works, i must missunderstand the challenge or something :/
1 Answer
Stone Preston
42,016 PointsDeclare a String variable named intAsString.
you have
String = intAsString;
Interger.toString(intAsString);
String = intAsString; does not declare a string variable. It most likely produces an error.
To simply declare the variable without assigning it anything you could do
String intAsString;
I think this line should help you out
String intAsString = Interger.toString(randomNumber);
I havent done the android videos and dont know java, but i think that may work