简体   繁体   English

字符串区分大小写

[英]Case sensitive order for Strings

There is a String.CASE_INSENSITIVE_ORDER but why is there no String.CASE_SENSITIVE_ORDER ? 有一个String.CASE_INSENSITIVE_ORDER但是为什么没有String.CASE_SENSITIVE_ORDER Or is there such an order somewhere hidden? 还是在某处隐藏了这样的命令?

Case-sensitive ordering is the default; 默认区分大小写; ie String#compareTo is case-sensitive. String#compareTo区分大小写。 Therefore, there is no explicit Comparator for it. 因此,没有明确的Comparator器。

Collections.sort(myStringList);  // case sensitive ("natural ordering")

Collections.sort(myStringList, String.CASE_INSENSITIVE_ORDER);  // case insensitive

因为默认情况下String.CASE_SENSITIVE_ORDER

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM