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 with Java Basic Android Programming Generating a Random Number

Jisan Reza
Jisan Reza
8,089 Points

from what I see in min 3:44 String + int = String ?

String + int = String

2 Answers

If 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
andren
28,558 Points

That 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.