java.util.LinkedHashMap.clear()%uA0方法删除所有来自此映射中的映射。此调用方法后映射将是空的。
声明
以下是java.util.LinkedHashMap.clear()方法的声明
public void clear()
参数
-
NA
返回值
此方法不返回任何值。
异常
-
NA
例子
下面的示例演示java.util.LinkedHashMap.clear()方法的用法。
package com.yiibai import java.util.* public class BitSetDemo { public static void main(String[] args) { // create a new linked hash map LinkedHashMap map = new LinkedHashMap(5) // add some values in the map map.put("One", 1) map.put("Two", 2) map.put("Three", 3) // print the map System.out.println("Map:" + map) // clear the map map.clear() // print the map System.out.println("Map:" + map) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Map:{One=1, Two=2, Three=3} Map:{}