获取Java IdentityHashMap中的一组值
要在IdentityHashMap中获取一组值,请使用values()方法。
首先,设置IdentityHashMap
Map<String, Integer> m = new IdentityHashMap<String, Integer>();
m.put("1", 100);
m.put("2", 200);
m.put("3", 300);
m.put("4", 150);
m.put("5", 110);
m.put("6", 50);
m.put("7", 90);
m.put("8", 250);
m.put("9", 350);
m.put("10", 450);现在,获取一组值
m.values()
以下是使用values()方法获取IdentityHashMap中的一组值的示例
示例
import java.util.*;
public class Demo {
public static void main(String[] args) {
Map<String, Integer> m = newIdentityHashMap<String, Integer>();
m.put("1", 100);
m.put("2", 200);
m.put("3", 300);
m.put("4", 150);
m.put("5", 110);
m.put("6", 50);
m.put("7", 90);
m.put("8", 250);
m.put("9", 350);
m.put("10", 450);
System.out.println("IdentityHashMap elements\n"+ m);
System.out.println("\nSet of Values = " + m.values());
}
}以下是输出
IdentityHashMap elements
{2=200, 4=150, 9=350, 7=90, 10=450, 6=50, 5=110, 8=250, 1=100, 3=300}
Set of Values = [200, 150, 350, 90, 450, 50, 110, 250, 100, 300]热门推荐
10 宝宝生日祝福语大全简短
11 足球队祝福语简短
12 过年爱情祝福语大全简短
13 同事离别祝福语简短的
14 生女儿的祝福语简短
15 对生活祝福语简短精辟
16 合字的祝福语简短
17 想念老公生日祝福语简短
18 许愿星姐妹祝福语简短