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 Basic Android Programming Using the Random Class

Aaron Maguire
Aaron Maguire
4,645 Points

I didn't see anything about the "intAsString" method in the videos. Could you help? Thanks

N/A

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

1 Answer

andren
andren
28,558 Points

intAsString is not a method, it is just the name they want you to use for the variable that ends up storing the String version of the int. In the video they showed that you can convert an int to a string by simply adding an int and a String together. No matter what the String contains (even if it is empty) simply adding an int to it will convert the int to a string.

So the code they are looking for is this:

String intAsString = randomNumber + ""
Aaron Maguire
Aaron Maguire
4,645 Points

That code didn't work for me. I have watched the video again and I am still having problems. Any other suggestions? Thanks