Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. public String put(String key, String value) {
  2.  
  3. //Checking if the key appears either in the file or the cache
  4. if(containsKey(key)) {
  5.  
  6. //Saves the old value
  7. String oldValue = get(key);
  8.  
  9. //replaces and returns
  10. tm.put(key, value);
  11. return oldValue;
  12. }
  13.  
  14. //Does not exist, so add to the cache
  15. else {
  16. tm.put(key, value);
  17. totalWords++;
  18. }
  19. return value;
  20. }
Add Comment
Please, Sign In to add comment