Name: _____________________________ 6 Digit StudentID: ___ ___ ___ ___ ___ ___

Worksheet 09: Map getOrDefault and computeIfAbsent

Given the documentation for java.util.Map:

get


getOrDefault


computeIfAbsent_a
computeIfAbsent_b

Write a do-it-yourself getOrDefault

V getOrDefault(Object key, V defaultValue)





Write a do-it-yourself computeIfAbsent

V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction)







Post Lecture

Synthesize today's class session

 

 

What is unclear?