Guest User

Untitled

a guest
Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public class HashTableBasic {
  2. public static void main(String[] args) {
  3. Hashtable<String, Integer> ht = new Hashtable<>();
  4.  
  5. ht.put("key", 0);
  6.  
  7. /*
  8. * Hashtable은 값에 null을 허용하지 않는다.
  9. */
  10. try{
  11. ht.put("key2", null); // error!
  12. } catch( Exception e ){
  13. e.printStackTrace();
  14. }
  15.  
  16. /*
  17. * Hashtable은 키값에 null을 허용하지 않는다.
  18. */
  19. try{
  20. ht.put(null, 0); // error!
  21. } catch( Exception e ){
  22. e.printStackTrace();
  23. }
  24.  
  25. // 해당 키 값을 가져온다.
  26. ht.get("key"); // 0
  27. }
  28. }
Add Comment
Please, Sign In to add comment