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

Can't Complete task 4.

How do i put in this string Variable?

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String fact = "";
Joyce Chidiadi
Joyce Chidiadi
1,867 Points

I am having the same problems. Adding this string variable has been on my neck over 30 minutes now. Please help with the RandomTest.java

I have this as my code: String[] intAsString = {""};

3 Answers

marioganzer
marioganzer
1,515 Points

In the video you can see the trick to convert any INT, DOUBLE, etc in a Sting, by using the '+'.

try to use: String intAsString = randomNumber + "";

Alwin Lazar V
Alwin Lazar V
5,267 Points

Random randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(10); String fact = randomNumber + "";

Joyce Chidiadi
Joyce Chidiadi
1,867 Points

Thank you Alwin and Marioganzer. That worked.