¼Ò½ºÄÚµå¶óÀ̺귯¸®  ¹è¿­  ÇؽÃÅ×ÀÌºí  

ÇØ½ÃÅ×À̺í

HashtableTest.java

import java.util.Hashtable;
public class 
HashtableTest {
    
public static void 
main(String[] args) {
        Hashtable hashtable = 
new 
Hashtable();
        
//1. hashtable¿¡ °´Ã¼ÀÇ »ðÀÔ    
        
hashtable.put("Name"new String("È«±æµ¿"
));
        hashtable.put(
"Age"new Integer(27
));
        hashtable.put(
"Tel"new String("02-1111-2222"
));
        hashtable.put(
"Handphone"new String("017-777-9999"
));
        hashtable.put(
"Etc"new String("I'm a boy"
));
        
//Ű °ªÀ» ÀÌ¿ëÇÏ¿© °´Ã¼ ÃßÃâ
        
String name = (String)hashtable.get("Name"
);
        
if (name != null
) {
            System.out.println(
"Name = " 
+ name);
        }
        Integer age = (Integer)hashtable.get(
"Age"
);
        
if (age != null
) {
            System.out.println(
"Age = " 
+ age.intValue());
        }
   }
}

C:\examples\6. Array>javac HashtableTest.java
C:\examples\6. Array>java HashtableTest
Name = È«±æµ¿
Age = 27

ÇØ½¬Å×À̺íÀº ۰ª°ú value°ªÀ» ½ÖÀ¸·Î ÀúÀåÇÏ´Â ÄÌ·º¼Ç·ù·Î½á put()¸Þ¼­µå¸¦ »ç¿ëÇÏ¿© ÀúÀåÀ» Çϰí get()¸Þ¼­µå¸¦ »ç¿ëÇÏ¿© °ªÀ» ºÒ·¯¿É´Ï´Ù.



jabookÀúÀÚ¸íÇÔ
Á¦¸ñ:°´Ã¼°³³ä¼Ò½ºÄÚµå
ÀúÀÚ:ÃÖ¿µ°ü