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?

    1 answer 1

    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); 
    • one
      Exhaustive answer. Thank! - androman
    • @androman, but not for that :) - Flippy