HashMap的一般用法以及遍历方法
private Map<Integer,String> selected = new HashMap<Integer,String>();
selected.put(key,value);
方法一:
Iterator it =selected .keySet().iterator();
while (it.hasNext())
{
Integer key=(Integer)it.next();
String xuehao=selected .get(key);
}
方法二:
Iterator it=adapter.getSelected().entrySet().iterator();//效率较高
while (it.hasNext())
{
Integer key=(Integer)it.next();
String xuehao=selected().get(key); }
HashMap的一般用法以及遍历方法的更多相关文章
- python基本数据类型list,tuple,set,dict用法以及遍历方法
1.list类型 类似于java的list类型,数据集合,可以追加元素与删除元素. 遍历list可以用下标进行遍历,也可以用迭代器遍历list集合 建立list的时候用[]括号 import sys ...
- HashMap的四种遍历方法,及效率比较(简单明了)
https://yq.aliyun.com/ziliao/210955 public static void main(String[] args) { HashMap<Integer, Str ...
- jQuery通用的全局遍历方法$.each()用法实例
1.jQuery通用的全局遍历方法$.each()用法 2. test.json文件代码: 3. html代码 4.jQuery代码 <script src="jquery-1.3.1 ...
- HashMap集合-遍历方法
# HashMap集合-遍历方法 先定义好集合: public static void main(String[] args) { Map<String,String> onemap=ne ...
- HashMap -双列集合的遍历与常用的方法
package cn.learn.Map; /* java.util.Hashtable<k,y> implements Map<k,v> 早期双列集合,jdk1.0开始 同步 ...
- HashMap有几种遍历方法?推荐使用哪种?
本文已收录<面试精选>系列,Gitee 开源地址:https://gitee.com/mydb/interview HashMap 的遍历方法有很多种,不同的 JDK 版本有不同的写法,其 ...
- ES6 数组遍历方法的实战用法总结(forEach,every,some,map,filter,reduce,reduceRight,indexOf,lastIndexOf)
目录 forEach every some map filter reduce && reduceRight indexOf lastIndexOf 前言 ES6原生语法中提供了非常多 ...
- 集合类List,set,Map 的遍历方法,用法和区别
遍历list: 方法一: for(String s:lists){ System.out.println(s); } 方法二: System.out.println("list with i ...
- map的三种遍历方法!
map的三种遍历方法! 集合的一个很重要的操作---遍历,学习了三种遍历方法,三种方法各有优缺点~~ /* * To change this template, choose Tools | Te ...
随机推荐
- dataStructure@ Binary Search Tree
#include<iostream> #include<cstdio> #include<cstring> #include<limits> #incl ...
- WebAPI 小知识
1.HttpResponseMessage.ReasonPhrase可以返回原因说明短语, 用JQuery中的$.ajax调用,返回函数第三个参数可以获取,如下: success:function(d ...
- 修改HTMLTestRunner模板
---恢复内容开始--- 1.修改bug(passCase不标色和加粗) style = (n == 2 and 'errorCase') or (n == 1 and 'failCase') or ...
- 剑指OFFER之把数组排成最小的数(九度OJ1504)
题目描述: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323. 输入: 输 ...
- MATLAB学习拾遗
1.坐标轴修饰 axis equal:axis([0,6,0,6]) 不修饰则为默认网格 grid on 2.不太漂亮的pretty命令 3. Laplace变换 syms t s a b f1=ex ...
- HDU 5433 Xiao Ming climbing dp
Xiao Ming climbing Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/ ...
- css3 字体旋转
<style> #mycon { font-weight: bold; font-size: 150px; transform: rotateX(10deg); -webkit-trans ...
- [AngularJS + cryptoJS + Gravatar] Provider vs factory
Configurable Bits Need a Provider We want to be able to configure the characterLength before Tweetab ...
- python的内存管理机制 图解+Django Web开发学习笔记
http://www.cnblogs.com/CBDoctor/p/3781078.html http://www.cnblogs.com/vamei/p/3232088.html http://bl ...
- careercup-中等难度 17.3
17.3 写一个算法计算n的阶乘末尾0的个数? 解答: 首先,算出n的阶乘的结果再去计算末尾有多少个0这种方法是不可取的, 因为n的阶乘是一个非常大的数,分分种就会溢出.我们应当去分析, 是什么使n的 ...