📜  java 数组检查重复项 - Java 代码示例

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

代码示例2
// Uses a set, which does not allow duplicates 

for (String name : names) 
{
     if (set.add(name) == false) 
     {
        // print name your duplicate element
     }
}