Why does the string s print "Hello, World" after converting to lower case?
public class Practice {
public static void main(String[] args){
String s = "Hello, World";
s.toLowerCase();
System.out.println(s);
}
}
Strings are immutable. You need to re assign the result of String#toLowerCase to the variable:
s = s.toLowerCase();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With