A null element can be added only if the Set contains one element because when a second element is added then as per set definition a check is made to check duplicate value and comparison with null element will throw NullPointerException.
HashSet is based on HashMap and can contain null element.