I have the string "22" and I’m getting 3 as length;
I used .trim()
What else could be a reason for this?
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.
You should be giving us code that demonstrates the problem, but my guess is you did something like this:
But
str.trim()doesn’t changestr(as Strings are immutable). Instead it returns a new String trimmed. So you need something like this: