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

I cant convert the int to a string!!!!

in task 3/3 of the code challenge "using a model in the controller" in the "build an interactive story app", I can't convert mSpaceship.getNumPassengers() into a string!!

Can you please link to the challenge? I remember doing this challenge yesterday lol, but I can't remember which one it is.

Ken Alger
Ken Alger
Treehouse Teacher

James;

Can you show the code you have tried?

Ken

2 Answers

One way is to use

String.valueOf(mSpaceship.getNumPassengers())

You can check out the Java docs here: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#valueOf(int)

thank you!!!!!

I've tried a couple of ways to do this while I was doing the course. Since all of them failed (not sure why) I just did a (+ "") which adds an empty string to the previous thing and converts the whole thing to a string. Tho I do not recommend getting use to this. It's better to use other ways. But as I said all of the ones I tried, failed.