本文链接:https://blog.csdn.net/TsuiXh/article/details/87879004
在开发中在使用Map时,如果需要将Map作为临时的数据存储和处理,可以不用每次都去新建一个Map,可以使用clear方法来进行清空Map。

Map<String, Object> map = new HashMap<>();
map.put("text", "hello");
System.out.print(map);
// Clear map
map.clear();
System.out.print(map)

  

输出如下:

{"text": "hello"}
{}

  

 

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-06-03
相关资源
相似解决方案