title: Why the internal implementation of HashSet creates dummy objects to insert as values in HashMap rather than inserting nulls?
body: <p>HashSet is implemented using HashMap and when we add anything say e1 to HashSet, internally it adds (e1,new Object()) in the HashMap if e1 was not present in the set. My question is why they are inserting new Object(), when they could have inserted like (e1,null), which is more optimized approach as no new Objects are created. Is there any downside to inserting nulls here?</p>