Advertisement
Guest User

How else stament made this changes?

a guest
Jan 27th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. Hi guys, I am in week 9 (Exercise 24) from the MOOC  course and I want to know how the else statement change the output... For instance:
  2.  
  3. public void add(String word, String entry) {
  4.        
  5.         if(!this.dictionary.containsKey(word)){
  6.             this.dictionary.put(word, new HashSet<String>());
  7.         }
  8.         else{
  9.            
  10.             this.dictionary.get(word).add(entry);
  11.         }
  12.     }
  13.  
  14.  
  15.  
  16. Output:
  17. [spruce]
  18. null
  19.  
  20. Version 2: (not "else")
  21. [six, spruce]
  22. null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement