📜  java 检查 3 个字符串是否相等 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:33.033000             🧑  作者: Mango

代码示例1
List strings = Arrays.asList("a", "b", "a", ...);
//One Way Of Doing It
if(new HashSet<>(strings).size() == 1) {
    // all strings are equal
}
//Another Way Of Doing Iz:
if(strings.stream().distinct().count() == 1) {
    // all strings are equal
}