size()%uA0方法用于获取在此标识哈希映射中的键 - 值映射关系数量。
声明
以下是java.util.IdentityHashMap.size()方法的声明。
public int size()
参数
-
NA
返回值
在方法调用返回键 - 值映射关系在这个映射中的数量。
异常
-
NA
例子
下面的例子显示java.util.IdentityHashMap.size()方法的使用
package com.yiibai import java.util.* public class IdentityHashMapDemo { public static void main(String args[]) { // create identity hash IdentityHashMap ihmap = new IdentityHashMap() // populate the ihmap ihmap.put(1, "java") ihmap.put(2, "util") ihmap.put(3, "package") System.out.println("Size of the map: " + ihmap.size()) } }
现在编译和运行上面的代码示例,将产生以下结果。
Size of the map: 3