从HashMap中提取值 [英] extracting values from HashMap

查看:121
本文介绍了从HashMap中提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从HashMap的工作中学习和理解.因此,我创建了此哈希图来存储某些值,这些值在使用Iterator进行显示时会显示为

I was trying to learn and make understanding out of the working of a HashMap. So i created this hashmap to store certain values which upon displaying using an Iterator gives me outputs as

 1=2
 2=3
 3=4

,依此类推.我使用Iterator.next()函数获得此输出.现在,我真正的疑问是,由于迭代器对象返回的该值的类型,如果我仅需要提取上述等式的右侧值,那么是否有任何功能?有点像子串.有什么办法可以让我得到

and so on. This output i obtain using the Iterator.next() function. Now what my actual doubt is that since the type of this value returned in of an Iterator Object, if i need to extract only the right hand side values of the above equalities, is there any function for that? Something like a substring. Is there any way i could just get results as

 2
 3
 4

任何帮助将不胜感激.预先感谢.

Any help will be appreciated. thanks in advance.

推荐答案

我会使用类似的

Map<Integer, Integer> map = new HashMap<>();

for(int value: map.values())
   System.out.println(value);

这篇关于从HashMap中提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆