!= not working for string

OK this is weird.

i have a string 12345.xxx

println(string.substring(string.length() - 3); // prints xxx to console

next line is:

if (string.substring(string.length() - 3) != "xxx")  {
  println(string + "yyy");
}

this is what prints to console:

12345.xxxyyy

It seems the if does not recognize the comparison!

I can't figure out why

Tagged:

Answers

Sign In or Register to comment.