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
James N
17,864 PointsI 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!!
Ken Alger
Treehouse TeacherJames;
Can you show the code you have tried?
Ken
James N
17,864 Pointshi, this is the url: https://teamtreehouse.com/library/build-an-interactive-story-app/finishing-the-user-interface/using-a-model-in-the-controller
thanks in advance!!!
2 Answers
Jack Middlebrook
19,746 PointsOne 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)
James N
17,864 Pointsthank you!!!!!
Kristian Terziev
28,449 PointsI'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.
Logan R
22,989 PointsLogan R
22,989 PointsCan you please link to the challenge? I remember doing this challenge yesterday lol, but I can't remember which one it is.