title: how to prevent hashmap or treemap from replacing the previous value
body: <p>how can I prevent hashmap or treemap from replacing the previous key value if already present?Also,I want to throw an exception to notify the user.</p>