Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HashTableBasic {
- public static void main(String[] args) {
- Hashtable<String, Integer> ht = new Hashtable<>();
- ht.put("key", 0);
- /*
- * Hashtable은 값에 null을 허용하지 않는다.
- */
- try{
- ht.put("key2", null); // error!
- } catch( Exception e ){
- e.printStackTrace();
- }
- /*
- * Hashtable은 키값에 null을 허용하지 않는다.
- */
- try{
- ht.put(null, 0); // error!
- } catch( Exception e ){
- e.printStackTrace();
- }
- // 해당 키 값을 가져온다.
- ht.get("key"); // 0
- }
- }
Add Comment
Please, Sign In to add comment