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 trial2 Answers
Douglas Benson
Courses Plus Student 2,490 PointsIf you are interested there is an alternative way of doing the conversion beside String + int. which is calling this method String.valueOf(int i) This method will return a String data type
andren
28,558 PointsThat is correct. When you concatenate (use the + operator on) two values and one of them is a String
it will try to convert the other value to a String
as well before it combines them.
It doesn't matter if it is int
+ String
or String
+ int
or even some other datatype than int
, as long as one of the values is a String
it will try to convert the other value into a String
as well.