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

Create a string variable "Moosh" together!

Help needed: Create a String variable named intAsString. Convert the randomNumber integer to a string variable. Hint ;Moosh" them together. Random randomGenerator = new Random(); Int randomGenerator.nextInt(10);

2 Answers

The variable you are starting with is of type String and you can't set the value of the int to it as the types are different. In some cases you could use the .toString() to convert it but if I recall, in this case, it will give you a reference that the int cannot be derefferenced. So there is a way that we can automatically convert the int to a string by usign the ""+ in front of the int portion of your code.

"" + Int randomGenerator.nextInt(10);

I believe. I am still pretty new to this stuff.

Thank you Bob, I really appreciate your help but unfortunately I tried that several time but with no luck, "Ben" the teacher gives problems which can be really difficult for us newbies, lol !!