What is the use of adding a null key or value to a HashMap in Java?

前端 未结 7 1417
挽巷
挽巷 2020-12-12 16:19

HashMap allows one null key and any number of null values. What is the use of it?

7条回答
  •  我在风中等你
    2020-12-12 16:43

    A null key can also be helpful when the map stores data for UI selections where the map key represents a bean field.

    A corresponding null field value would for example be represented as "(please select)" in the UI selection.

提交回复
热议问题