目录

int size()

描述 (Description)

size()方法用于获取此标识哈希映射中键 - 值映射的数量。

声明 (Declaration)

以下是java.util.IdentityHashMap.size()方法的声明。

public int size()

参数 (Parameters)

NA

返回值 (Return Value)

方法调用返回此映射中键 - 值映射的数量。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.util.IdentityHashMap.size()的用法

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018