Java字符串未转换为小写 [英] Java string not converted to lower case
本文介绍了Java字符串未转换为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么字符串 s
转换为小写字母后会打印"Hello,World"
?
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);
}
}
推荐答案
String
是不可变的.您需要将 String#toLowerCase
的结果重新分配给变量:
String
s are immutable. You need to re assign the result of String#toLowerCase
to the variable:
s = s.toLowerCase();
这篇关于Java字符串未转换为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文