Java string not converting to lowercase
2 answers
Strings are a special kind of objects in Java. The Java developers deliberately created them to be immutable (for various security and performance reasons).
This means that when you think you are changing the state of a String object, a new String object is actually being created (and the previous one is not changed).
Therefore, to make your code work, you need to assign the result of the method to some line:
s = s.toLowerCase();
+2
source to share