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());
}
}
}