¼Ò¼³ java.util ¼Ò½ºÄڵ堠Set  SetÀÇ ¿ä¼ÒÃß°¡  

SetÀÇ ¿ä¼ÒÃß°¡

TestHashSet.java

import java.util.*;

public class TestHashSet {
  
public static void main(String args[]) {
    HashSet hs = 
new HashSet();

    hs.add(
new Integer(4));
    hs.add(
new Integer(2));
    hs.add(
new Integer(1));
    hs.add(
new Integer(3));

    System.out.println(
"The capacity of hs is " + hs.size());
    System.out.println(
"hs contains " + hs);
  } 
}

D:\java\util>javac TestHashSet.java
D:\java\util>java TestHashSet
The capacity of hs is 4
hs contains [4, 3, 2, 1]

SetÀÎÅÍÆäÀ̽ºÀÇ add()¸Þ¼­µå¸¦ ÀÌ¿ëÇÏ¿© ¿ä¼ÒµéÀ» »ðÀÔÇÕ´Ï´Ù.



jabookÀúÀÚ¸íÇÔ
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå
ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è¿Ï±â