int vozrast; String rezultat; vozrast=31; rezultat="Мой новый возраст: " + vozrast+1; In this case, the result will be
My new age: 311
Need
My new age: 32
How is it better to organize?
The expected turns into a string, since the + operator is overloaded and can add not only numbers, but also strings. In your case, first comes the addition of the string with the variable vozrast . The result is a string, but it already thinks that + further means concatenation. So that the addition is performed first and only then the concatenation concludes the addition in brackets
rezultat = "Мой новый возраст: " + (vozrast + 1); Source: https://ru.stackoverflow.com/questions/646543/
All Articles