Create a public class called Inverter
with a single class method named invert
.
invert
should accept a Map<String, Integer>
and return a Map<Integer, String>
with all of the key-value
pairs swapped.
You can assert that the passed map is not null
.
Because values are not necessarily unique in a map, normally you would need a way to determine what the right approach is when two keys map to the same value. However, the maps passed to your function will not have any duplicate values.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: