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

Stuck at challenge task 4 of 4!

I'm still a bit unclear of the purpose of declaring a string named intAsString,as well as how to go about it.

I am a bit loss as to the definition of "variable" and "class", as well as their purpose in Java codings.

Regards

1 Answer

Stone Preston
Stone Preston
42,016 Points

you can declare a string like so:

String someString = "some string";

however in your case you need to convert the integer variable you created previously (randomNumber) to a string using the toString method of the Integer class (it takes an integer as an argument). since its a class method you call it like this (Note: the following code is just an example, you will have to make a few changes to make it work for your challenge)

   int myInt = 10;
   String someString =  Integer.toString(myInt);