Twelfth records of career

December 7,2016.

Every time i do something quietly ,i don't do it too long,but code to work quietly , so every time you have to force youself to calm down to learn,it is because of this i do not know how long it can persist,or can not let it become a habit ?

The teachers are said to play more code to do more exercise,do this for code played more is the hard truth.is seems to be play some of the code ,and is doomed to have no time to go to sleep.at noon sleep,wake up after the discovery to sleep is a happy thing.

Now say that the hard work, the future can not see hope, then the road so far, how to do?

现在就说辛苦,对未来看不到希望,那以后的路还那么远那该怎么办??

        NOTES

package testmap;


import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;


public class TestMap {
public static void main(String[] args) {
HashMap<String, String>  hm=new HashMap<String, String>();
//将“abc”存入集合   它 的键是“01”
hm.put("01", "abc");
hm.put("00", "abcd");

//当存有的数据的键已有时    会覆盖对应的之前的值   方法的返回值是被取代的值
System.out.println(hm.put("01", "aaaaaaaaa"));
System.out.println(hm.size());
//删除对应的键的数据   返回值是被删除的键对应的值
System.out.println(hm.remove("01"));
System.out.println(hm.size());
System.out.println(hm);
//通过传入的键获取到他相应的值
System.out.println(hm.get("00"));
//判断集合是否包含某个键
System.out.println("有这个键吗?"+hm.containsKey("001"));
//判断集合是否包含某个值
System.out.println("是否存在abc"+hm.containsValue("abc"));

//
Set<String> keySet=hm.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
//通过方法获取到的键  使用get()方法获取对应的值
System.out.println("hm里面的键: "+key+"对应的值为: "+hm.get(key));
}
Set<Entry<String,String>> entrySet=hm.entrySet();
for (Iterator<Entry<String, String>> iterator = entrySet.iterator(); iterator.hasNext();) {
Entry<String, String> entry=iterator.next();
System.out.println(entry.getKey()+"*****"+entry.getValue());

}
}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值