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

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

Declare a String variable named intAsString. Convert the randomNumber integer to a String value and store it in the intA

Help Me

RandomTest.java
Random randomGenerator = new Random();
int RandomNumber = randomGenerator.nextInt(10);
fact = randomNumber + "";

3 Answers

Hello,

You're close, this task is asking you to declare a String named intAsString instead what you called fact.

I'm having the same problem. My answer was the following:

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

Hello,

You forgot to declare your intAsString variable and give it a type. You can either do that on the same line or on a seperate line. For example,

int someInt = 0;

has the type, variable name, and value all one one line. You could also just declare a variable then initialize it on another line by

int someInt;
someInt = 0;
T K
T K
1,875 Points

The code goes like this...

Random randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(10);

(Till here you have done...the next step is to DECLARE the 'intAsString' as a String....it is to be done the following way)

String intAsString = "";

(And then 'Moosh' up the variables)

intAsString = randomNumber + "";