How would I add something to the end of a string, like an integer?
Example:
int i = 0;
String string = Integer.toString(i);
string = string + suffix;
I tried using the plus sign to add the suffix but it didn’t work. Any help?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code you’ve given will work absolutely fine:
My guess is that in your real code, you aren’t assigning the result back to the variable. Note that the
+operator doesn’t modify the existing string – it creates a new string. So: