"Modern WordPress Workflow" was retired on June 9, 2017.

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 (retired 2014) Learning the Language Objects and Random Numbers

Do not understand..

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.

what is wrong? ```Random randomGenerator = new Random(); int randomNumber = randomGenerator. nextInt(10); answer = Integer. toString(randomNumber);

12 Answers

I think that you're not supposed to have a space after Integer.

Hello,

In this code you have a space between Integer. and toString. Try removing that space.

You have:

answer = Integer. toString(randomNumber);

You want this:

answer = Integer.toString(randomNumber);

Hope this helps, if not let me know.

Paul :)

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

did not help

Sorry, there's more errors than initially thought.

You also have a space after randomGenerator. It was hard to tell from original post because that's where the line break occurred.

Also, your last line of code doesn't match up with the directions for task 4. It's saying, Declare a String variable named intAsString

Ok, I also notice that is asking you to store the result in the "intAsString" variable, at the moment this code is storing it in the variable "answer"

You have:

answer= Integer.toString(randomNumber);

Try this instead:

intAsString = Integer.toString(randomNumber);

Paul :)

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

still saying syntax error

You didn't declare it as a String type.

Try this

Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString; //declare the variable
intAsString = Integer.toString(randomNumber); //assign the value to the string

Paul :)

Or you maybe can combine the lines to this:

String intAsString = Integer.toString(randomNumber);

Paul :)

^ last line should read like this

String intAsString = Integer.toString(randomNumber);