 <p><code>keySet()</code> does not create a new <code>Set</code>. </p> <p>It simply offers a view of the keys in your map. It actually provides only a few operations which are iteration (with remove), size, emptiness, clear and contains. You cannot add an element to it otherwise it will throw an <code>UnsupportedOperationException</code>.</p>