adding a key to HashMap without the value?

前端 未结 5 2243
孤城傲影
孤城傲影 2021-02-19 14:37

Is there a way to add a key to a HashMap without also adding a value? I know it seems strange, but I have a HashMap> amd I wan

5条回答
  •  猫巷女王i
    2021-02-19 14:53

    You can put null values. It is allowed by HashMap

    You can also use a Set initially, and check it for the key, and then fill the map.

提交回复
热议问题