Áߺ¹±ÛÀÚ¿Í À¯ÀÏÇÑ ±ÛÀÚ ÆÇº°
FindDups2.java
import java.util.*;
public class FindDups2 {
public static void main(String args[]) {
Set unique = new HashSet();
Set dupe = new HashSet();
for (int i=0; i<args.length; i++){
if (!unique.add(args[i])){
dupe.add(args[i]);
}
}
unique.removeAll(dupe); // Destructive set-difference
System.out.println("À¯ÀÏÇÑ ±ÛÀÚ : " + unique);
System.out.println("Áߺ¹µÈ ±ÛÀÚ : " + dupe);
}
}
D:\java\util>javac FindDups2.java
D:\java\util>java FindDups2 a c c d e b d d e
À¯ÀÏÇÑ ±ÛÀÚ : [b, a]
Áߺ¹µÈ ±ÛÀÚ : [e, d, c]
Áߺ¹µÈ ±ÛÀÚ¿Í À¯ÀÏÇÑ ±ÛÀÚ ±¸º°ÇÏ¿© Ãâ·Â
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è¿Ï±â |