前沿拓展:
eee4444
手機靚號,通俗講,即有規(guī)律的排列,順口或有多個重復排列,組合循環(huán)等的受歡迎的手機號,當策行親反家面探但過半然,除以上外還包括吉利數(shù)字習俗的重復排列,組合循環(huán)錯班相趙頭部客策題益等,如四連號8888、6666……那在河南辦理一個手機四連號需要多少錢呢?下邊帶您了解。
1、看一些老號碼了,保底的高低也是價格浮動的一個縮漢評調(diào)養(yǎng)統(tǒng)弦述指費很重要因素。
1、Map概述
1.1 什么是Map
Map是將
3.22.HashMap與Hashtable的異同
除了非同步和允許使用 null 之外,HashMap 類與 Hashtable 大致相同
3.23.HashMap的使用示例
public class HashMapReview {
public static void main(String[] args) {
test1();
test2();
} /**
* 自定義類型做key,
* 需重寫其equals和hashCode方法才能保證其key的唯一性
*/
private static void test2() {
HashMap<Info, String> map=new HashMap<Info, String>();
map.put(new Info(0, “aaa”),”0000″);
map.put(new Info(1, “bbb”),”1111″);
map.put(new Info(3, “ddd”),”3333″);
map.put(new Info(0, “aaa”),”4444″);
map.put(new Info(2, “ccc”),”2222″);
printMap(map); // output:// key=Info [id=3, adress=ddd] value=3333// key=Info [id=2, adress=ccc] value=2222// key=Info [id=0, adress=aaa] value=0000// key=Info [id=1, adress=bbb] value=1111// key=Info [id=0, adress=aaa] value=4444 // 當Info沒有重寫equals和hashCode方法時,key出現(xiàn)重復元素
} /**
* String或基本數(shù)據(jù)類型的包裝類做key,他們已重寫了hashCode與equals方法
* 鍵唯一,重復添加會替換舊值成新值
*/
private static void test1() {
HashMap<String, String> map=new HashMap<String, String>();
map.put(“aaa”, “123”);
map.put(“bbb”, “789”);
map.put(“aaa”, “456”);
map.put(“ccc”, “321”);
System.out.println(map); // output:// {aaa=456, ccc=321, bbb=789}
// 重復的鍵不會重新插入,只會替換舊值成新值
} private static void printMap(Map<Info, String> map) {
Set<Entry<Info, String>> entrySet = map.entrySet(); for (Entry<Info, String> entry : entrySet) {
System.out.println(“key=”+entry.getKey()+” value=”+entry.getValue());
}
}
}
3.24 一個HashMap面試題
需求如下:
已知一個HashMap<Integer,Person>**, Person有name(String)和age(int)屬性。
請寫一個方法實現(xiàn)對HashMap的排序功能。該方法接收HashMap<Integer,Person>為形參,返回類型為HashMap<Integer,Person>,要求對HashMap中的Person的age升序進行排序。排序時key=value鍵值對不得拆散。
分析:
HashMap本身是不保證元素的順序不變的,要對其排序可使用LinkedHashMap,它是有序的并且還是HashMap的子類,我們可以使用它來完成排序的目的。最后返回它的實例即可滿足要求 并且還符合多態(tài)的編程思想
示例代碼
public class SortedHashMapDemo { public static void main(String[] args) {
HashMap<Integer, Person> map = new LinkedHashMap<Integer, Person>();
map.put(0, new Person(“小明”, 20));
map.put(1, new Person(“小二”, 26));
map.put(2, new Person(“小四”, 19));
map.put(3, new Person(“阿七”, 33));
map.put(4, new Person(“十四”, 25));
map.put(4, new Person(“小花”, 19));
System.out.println(map);
HashMap<Integer, Person> sortedHashMap = SortedHashMap(map);
System.out.println(sortedHashMap);
} public static HashMap<Integer, Person> SortedHashMap(
HashMap<Integer, Person> map) { // 獲得鍵值對Set**
Set<Entry<Integer, Person>> entrySet = map.entrySet(); // 將鍵值對Set**轉(zhuǎn)化為List以用Collections來排序
List<Entry<Integer, Person>> list = new ArrayList<Map.Entry<Integer, Person>>(
entrySet); // 通過Collections來排序,添加比較器,比較年齡
Collections.sort(list, new Comparator<Entry<Integer, Person>>() {
@Override public int compare(Entry<Integer, Person> o1, Entry<Integer, Person> o2) { int result = o2.getValue().age – o1.getValue().age;
result = result == 0 ? o2.hashCode() – o1.hashCode() : result; return result;
}
}); // 創(chuàng)建LinkedHashMap來存儲排好序的List元素
LinkedHashMap<Integer, Person> linkedHashMap = new LinkedHashMap<Integer, Person>(); // 遍歷List,將元素添加到linkedHashMap中
for (Entry<Integer, Person> entry : list) {
linkedHashMap.put(entry.getKey(), entry.getValue());
} return linkedHashMap;
}
}
class Person {
String name; int age; public Person(String name, int age) {
super(); this.name = name; this.age = age;
}
@Override public String toString() { return “Person [name=” + name + “, age=” + age + “]”;
}
}
拓展知識:
eee4444
http://xiangce.baidu.com/picture/album/list/84912c87cedd2e7b44935b8008d859e9f24b9bbc
http://xiangce.baidu.com/picture/album/list/4e3bfe84ca156ecfde92f66de23f0d529415c3bc
http://xiangce.baidu.com/picture/album/list/0aa0d82df177affd2d9fbec53de48222862ad1bc
http://xiangce.baidu.com/picture/album/list/cb85b8a6b03a80689257b7bd6700623b6a37f3bc
http://xiangce.baidu.com/picture/album/list/7d0692c75b2d45037be1a8cdfcbaea415a9e3ebc
http://xiangce.baidu.com/picture/album/list/3bb7003d5f13e02d9c51714243cc3134eef256bc
http://xiangce.baidu.com/picture/album/list/e0a7270b956ad04f1f4cacf1bcbcc7774f5b66bc
http://xiangce.baidu.com/picture/album/list/758cc0c8471a899e049c8b7183bfe95c77084d9a
http://xiangce.baidu.com/picture/album/list/d59d39fcd02f0a-底部咨詢-ecf741c697bc0bd
http://xiangce.baidu.com/picture/album/list/4b40ef1303bdceddfcdc0b0bc59608d858e99a9b
http://xiangce.baidu.com/picture/album/list/646b12de8222872a14444e3740d96ffc9d9ad69b
http://xiangce.baidu.com/picture/album/list/4467f167ec19c23a588aeca9ca40c984183437bd
http://xiangce.baidu.com/picture/album/list/443e2fec23f30cf1edc705c9d63d7a2aae58009b
http://xiangce.baidu.com/picture/album/list/a8935711fb0e9eeee893cfc0450e19b2254c87be
http://xiangce.baidu.com/picture/album/list/24b6cc3aa41f083199cd4d5912c232e7bdbc649b
http://xiangce.baidu.com/picture/album/list/eb459a2b20d33de419ae193c8ae3d32141d9d4be
http://xiangce.baidu.com/picture/album/list/d3249f008068e8d95227f916623b6b379524f4be
http://xiangce.baidu.com/picture/album/list/674b23cb856098dfbfb1e43caf584d08006a02be
http://xiangce.baidu.com/picture/album/list/7d0692c75b2d45037be3a8cdfcbaea415a9e3ebe
http://xiangce.baidu.com/picture/album/list/3b4195595077a2d69976c211600fedff7e931284
http://xiangce.baidu.com/picture/album/list/a7b88b250831956adcc38cd432e7bcbcc67765be
http://xiangce.baidu.com/picture/album/list/fbc0d51f9c63dc1d0bcba8f75700b5da8a5caabf
http://xiangce.baidu.com/picture/album/list/646b12de8222872a17684d3740d96ffc9d9ad6bf
http://xiangce.baidu.com/picture/album/list/1f262fe5de5dec19fc9ffb1172bfca40c8843685
http://xiangce.baidu.com/picture/album/list/3bb7003d5f13e02d9f7a724243cc3134eef25685
http://xiangce.baidu.com/picture/album/list/33c5266bd4d1748731f844f5be33ec2b792b8086
http://xiangce.baidu.com/picture/album/list/2b44b3a07d2b9125b24c4e390a83d1becb15cdb8
http://xiangce.baidu.com/picture/album/list/c88836af27f2bf7845810175dc1dca4037e1b786
http://xiangce.baidu.com/picture/album/list/2cc3cd050d52951550d063120c8123409730b886
http://xiangce.baidu.com/picture/album/list/23b84d016b379424d756f602fc7cc47fbe38e986
http://xiangce.baidu.com/picture/album/list/812e27e259e9f34b18dbb238eecf7fd6dd2a9087
http://xiangce.baidu.com/picture/album/list/0aa0d82df177affd2cb3bdc53de48222862ad180
http://xiangce.baidu.com/picture/album/list/bfb6b1d4061f51d6b58987a4244c49d2e41979ba
http://xiangce.baidu.com/picture/album/list/ef8db03db4bd583f2ecb590e894c77f686dfd8a5
http://xiangce.baidu.com/picture/album/list/b5cf80c7b51120d3a67b1f34872a8ae3d221d383
http://xiangce.baidu.com/picture/album/list/cb85b8a6b03a80689345b4bd6700623b6a37f38e
http://xiangce.baidu.com/picture/album/list/99735b3de716600eeb783a090831956ad14f61aa
http://xiangce.baidu.com/picture/album/list/d8dbf327ca4036e1939128cc8b5c82dafeb3acb1
http://xiangce.baidu.com/picture/album/list/cb85b8a6b03a806892afb7bd6700623b6a37f354
http://xiangce.baidu.com/picture/album/list/c662d089d9e6f9745bbbcb7602d80ff8c129a3b2
http://xiangce.baidu.com/picture/album/list/37027d2d39bebdfd685bdb154e6f36dbfdba3c54
http://xiangce.baidu.com/picture/album/list/e66eecea5f07600fb18de185282ecbabc2491550
http://xiangce.baidu.com/picture/album/list/ade45932f83b5625e3d5ca629736c0c372ba4450
http://xiangce.baidu.com/picture/album/list/6b96c1f57fd6dc2a2461ca2c58b5d-底部咨詢-
http://xiangce.baidu.com/picture/album/list/8682493d72bfca408b0884226a64dafec7212abe
http://xiangce.baidu.com/picture/album/list/a495aee5ef5443cc10b872e4471a899e203449be
http://xiangce.baidu.com/picture/album/list/5397fde9ddcb7407e09afd18e300a41f09316fbe
http://xiangce.baidu.com/picture/album/list/2edcf5c4c6212ac7c866d9c9e7d3b3126a192051
http://xiangce.baidu.com/picture/album/list/32b0d7015625c8a778050920c0c373ba53174551
http://xiangce.baidu.com/picture/album/list/2ab891158bcf2119365f878327f2bf78fb25b353
http://xiangce.baidu.com/picture/album/list/ce5bfc1b40d96ffc3df5e33d912516c6d12fca53
http://xiangce.baidu.com/picture/album/list/830f0af16edd8f3de0f32e2c8068e8d928abf053
http://xiangce.baidu.com/picture/album/list/65a1a30a199527f201f167339c63dc1dcb40b6b9
http://xiangce.baidu.com/picture/album/list/aef974a400dfde5dd0765c2c660772bfcb403553
http://xiangce.baidu.com/picture/album/list/c1e11418f228172fd1bc43dd7407e716610e6c53
http://xiangce.baidu.com/picture/album/list/1082778fd971230670bf9113777d0951d5d18a5c
http://xiangce.baidu.com/picture/album/list/945528860ecd6a239ae5e7c87f0f2f075e1350b9
http://xiangce.baidu.com/picture/album/list/156e6a3419b2244cbd5a780fde86e23bb4567cb9
http://xiangce.baidu.com/picture/album/list/8a650141961dc596dd50c4fff34bc0782e2e9dba
http://xiangce.baidu.com/picture/album/list/646b12de8222872a146b4e3740d96ffc9d9ad6ba
http://xiangce.baidu.com/picture/album/list/7f9add12172fd2d3d9a5ea11e716600ee2006d5c
http://xiangce.baidu.com/picture/album/list/da56292551d6450ee8dfba5a49d2e519df867a5c
http://xiangce.baidu.com/picture/album/list/16af1684bdfd5b2d708bd37936dbfcbaeb413dba
http://xiangce.baidu.com/picture/album/list/2e9bad567ade7f0f348fc205e02d81dfee5453ba
http://xiangce.baidu.com/picture/album/list/01b63688244c49d2109e4390e23bb55679057dba
http://xiangce.baidu.com/picture/album/list/4849aa5a98dfd63d1047314e4d08016a103f035d
http://xiangce.baidu.com/picture/album/list/1f956a394e6f36dbcbd774575b9e00dfdf5d305d
http://xiangce.baidu.com/picture/album/list/d09c79c86b14fc7c40f8222e9945a014a81decbb
http://xiangce.baidu.com/picture/album/list/8768703d600fedff2114b538cbabc3493aa916bb
http://xiangce.baidu.com/picture/album/list/7259783ab5da8b5c44b661a5d9e6f974912baf5e
http://xiangce.baidu.com/picture/album/list/0ae3b2e9d0ed07bc184af735826c7ade7e0f5ebb
http://xiangce.baidu.com/picture/album/list/1c878e74c718894ce59a19c94e18f717f077db5e
http://xiangce.baidu.com/picture/album/list/6c96e491c3493ba9b59f9e9000d623f30df10b5e
http://xiangce.baidu.com/picture/album/list/8ead41f5741c687b4fb990449515e074ff04c5a4
http://xiangce.baidu.com/picture/album/list/ab4a6820899e2134330b1da9e95c7608f93b4e5e
http://xiangce.baidu.com/picture/album/list/8f13ec733ba9d7f364009dc023f30cf184600ca4
http://xiangce.baidu.com/picture/album/list/4e3bfe84ca156ecfde77f66de23f0d529415c35f
http://xiangce.baidu.com/picture/album/list/9a3ecd01b5567805793cbee7f164c466baba72a4
http://xiangce.baidu.com/picture/album/list/443e2fec23f30cf1e20b06c9d63d7a2aae58005f
http://xiangce.baidu.com/picture/album/list/d1adcf4efe040c8190c50b26fd5fcaf76f00bba5
http://xiangce.baidu.com/picture/album/list/129de79d54749736eea8edac521739bebcfd475f
http://xiangce.baidu.com/picture/album/list/443e2fec23f30cf1ede505c9d63d7a2aae5800a5
http://xiangce.baidu.com/picture/album/list/f7aa4423604402c24db6b95c30294a86c41227a5
http://xiangce.baidu.com/picture/album/list/1f956a394e6f36dbc43f77575b9e00dfdf5d30a5
http://xiangce.baidu.com/picture/album/list/48390c7a9630fd5f7f9df016be2f8bcf2019be58
http://xiangce.baidu.com/picture/album/list/795cad18872a8ae34d4bdecf6ffc9c9a7c2bd758
http://xiangce.baidu.com/picture/album/list/6d13483a623b6b37eb4ec8e46b14fc7cc57fe858
http://xiangce.baidu.com/picture/album/list/1bbf4f35edff7f93764455bdc3493ba9d6f31758
http://xiangce.baidu.com/picture/album/list/97996fe36ffc9c9adeaf0c3316c6d02f0b83cba6
http://xiangce.baidu.com/picture/album/list/7d0692c75b2d45037b05a8cdfcbaea415a9e3e58
http://xiangce.baidu.com/picture/album/list/3b2b0714cbabc349592d4ae5008600d622f30aa6
http://xiangce.baidu.com/picture/album/list/7f9add12172fd2d3d9a1ea11e716600ee2006d58
http://xiangce.baidu.com/picture/album/list/8d3c360e6a64dafe80a5b7d18f1747dfe6d32ea6
http://xiangce.baidu.com/picture/album/list/1d51dc71c0782f2e37a6e1c0dc2af810553a9259
http://xiangce.baidu.com/picture/album/list/4e3bfe84ca156ecfde75f66de23f0d529415c359
http://xiangce.baidu.com/picture/album/list/2edcf5c4c6212ac7c87ed9c9e7d3b3126a192059
http://xiangce.baidu.com/picture/album/list/124a442efc7cc47f3abb0453a014a91d06e0eda7
http://xiangce.baidu.com/picture/album/list/f1ee573f83b923f10a0c5a70bbbaa-底部咨詢-
http://xiangce.baidu.com/picture/album/list/d2a5eaac08d859e925235e6e2f2eeecf7ed69f5a
http://xiangce.baidu.com/picture/album/list/795cad18872a8ae34d49decf6ffc9c9a7c2bd75a
http://xiangce.baidu.com/picture/album/list/cb85b8a6b03a806892b1b7bd6700623b6a37f35a
http://xiangce.baidu.com/picture/album/list/37ab50c3ba635077fabe5dc65f07600fecff115a
http://xiangce.baidu.com/picture/album/list/527eff150a83d1be6397f3d9741c687be33fc1a0
http://xiangce.baidu.com/picture/album/list/945528860ecd6a239504e4c87f0f2f075e13505a
http://xiangce.baidu.com/picture/album/list/303ff666d9e3be33064ce63dfb0e9eee071f835b
http://xiangce.baidu.com/picture/album/list/84912c87cedd2e7b447a5b8008d859e9f24b9b5b
http://xiangce.baidu.com/picture/album/list/a495aee5ef5443cc10b672e4471a899e203449a0
http://xiangce.baidu.com/picture/album/list/01b63688244c49d210984390e23bb55679057da0
http://xiangce.baidu.com/picture/album/list/303ff666d9e3be3307aae53dfb0e9eee071f83a1
http://xiangce.baidu.com/picture/album/list/0e3eea28e77b73132a9e24755077a2d6c2d01e5b
http://xiangce.baidu.com/picture/album/list/c3676122f717f177377c280720d33de48322d0a1
http://xiangce.baidu.com/picture/album/list/cb85b8a6b03a80689358b4bd6700623b6a37f3a1
http://xiangce.baidu.com/picture/album/list/2fa14f7e02c2023374cbad3f4a86c512e67b18a1
http://xiangce.baidu.com/picture/album/list/7263d380ea415b9e3b5e434bec19c23a670733a1
http://xiangce.baidu.com/picture/album/list/2facd346c47fbf381c233e02a91d07e01ce9ee44
http://xiangce.baidu.com/picture/album/list/24b7c2c57f93282e94cd5d5f3ba9d7f301860844
http://xiangce.baidu.com/picture/album/list/1f262fe5de5dec19ff5cf81172bfca40c8843644
http://xiangce.baidu.com/picture/album/list/5951600cab359f073a3dc529a14ec718884ce6a2
http://xiangce.baidu.com/picture/album/list/b6903815d2d3ddcb-底部咨詢-ee300a51f6e44
http://xiangce.baidu.com/picture/album/list/9892d72a543a58b50614bd1091d10f05767d8845
http://xiangce.baidu.com/picture/album/list/4467f167ec19c23a5987efa9ca40c984183437a2
http://xiangce.baidu.com/picture/album/list/758cc0c8471a899e04b48b7183bfe95c77084da2
http://xiangce.baidu.com/picture/album/list/277221a96c7bc7b751aef0cb8f3d979cb13afd45
http://xiangce.baidu.com/picture/album/list/d2a5eaac08d859e924345d6e2f2eeecf7ed69fa3
http://xiangce.baidu.com/picture/album/list/a4ccd13e0c812340224f6049caf76e00bf2fbca3
http://xiangce.baidu.com/picture/album/list/765f9386c7774e5b8fb64efb07bc0ecd6b235b45
http://xiangce.baidu.com/picture/album/list/5397fde9ddcb7407e173fe18e300a41f09316f45
http://xiangce.baidu.com/picture/album/list/3cbdac8323f1f164380225aca54185593a227545
http://xiangce.baidu.com/picture/album/list/3993be1f16c6d02face74fa8ca156ecf751ccf46
http://xiangce.baidu.com/picture/album/list/f0057705a14ec7181828e9e087df4e18f6**46
http://xiangce.baidu.com/picture/album/list/466020c2c02903bd1fa3b36d961dc59609d899ac
http://xiangce.baidu.com/picture/album/list/f162a46682daffb-底部咨詢-2b566003d8a1ac
http://xiangce.baidu.com/picture/album/list/2ab891158bcf2119374e848327f2bf78fb25b3ac
http://xiangce.baidu.com/picture/album/list/3e6650352f075f13fc491fc9ef5443cc30345546
http://xiangce.baidu.com/picture/album/list/a6839a6c780583b9d9926f72c466bbbaa4417346
http://xiangce.baidu.com/picture/album/list/6b96c1f57fd6dc2a2473ca2c58b5d-底部咨詢-
http://xiangce.baidu.com/picture/album/list/65a1a30a199527f2021b64339c63dc1dcb40b647
http://xiangce.baidu.com/picture/album/list/a4ccd13e0c-底部咨詢-349caf76e00bf2fbc47
http://xiangce.baidu.com/picture/album/list/b6903815d2d3ddcb72797a00600ee300a51f6eac
http://xiangce.baidu.com/picture/album/list/42a77eec450e19b2d731d4c4e519de86e33b7bac
http://xiangce.baidu.com/picture/album/list/9892d72a543a58b5390cbe1091d10f05767d88ad
http://xiangce.baidu.com/picture/album/list/1fbf4cf00e936c7bb4d4bbdd6edd8f3d969cfc47
http://xiangce.baidu.com/picture/album/list/65a1a30a199527f2010567339c63dc1dcb40b6ad
http://xiangce.baidu.com/picture/album/list/2a775b26687be23fa32f0803e074fe040d81c6ad
http://xiangce.baidu.com/picture/album/list/97996fe36ffc9c9ade560c3316c6d02f0b83cbad
http://xiangce.baidu.com/picture/album/list/dbbf9b87583fa14e5665145a77f687df4f18d9ad
http://xiangce.baidu.com/picture/album/list/c4d0c7e329ab67001c46f621942456f26a14f6ad
http://xiangce.baidu.com/picture/album/list/92855510af584d086f178c295b0763ca0f9306ad
http://xiangce.baidu.com/picture/album/list/a3ae4f34e300a41f02520b7cd04f12c233e76347
http://xiangce.baidu.com/picture/album/list/2fa14f7e02c202337437ad3f4a86c512e67b18ad
http://xiangce.baidu.com/picture/album/list/90695bbdd95cd9e35751723d782bfb0e9fee8240
http://xiangce.baidu.com/picture/album/list/6b96c1f57fd6dc2a2472ca2c58b5d-底部咨詢-
http://xiangce.baidu.com/picture/album/list/9d5ed64e902b5660ceba91eec02903bdcfdda540
http://xiangce.baidu.com/picture/album/list/7259783ab5da8b5c44b861a5d9e6f974912baf40
http://xiangce.baidu.com/picture/album/list/b9e7e5cd6e00be2f33adbf0f8c30199526f2b140
http://xiangce.baidu.com/picture/album/list/046140c69c9a7d2b324788d0d02f0a83d0becc40
http://xiangce.baidu.com/picture/album/list/9a3ecd01b556780579c5bee7f164c466baba72ad
http://xiangce.baidu.com/picture/album/list/c4d0c7e329ab67001f59f521942456f26a14f640
http://xiangce.baidu.com/picture/album/list/ebe06232016a113f3465fddc0e936c7bc6b7f840
http://xiangce.baidu.com/picture/album/list/e66eecea5f07600fb19de185282ecbabc2491540
http://xiangce.baidu.com/picture/album/list/468b0b7030294a869770796d73137ff9bb631b40
http://xiangce.baidu.com/picture/album/list/2cc3cd050d-底部咨詢-3120c8123409730b8ae
http://xiangce.baidu.com/picture/album/list/10ccb80cc0c373ba6275a7a8bdfd5b2d44033940
http://xiangce.baidu.com/picture/album/list/435832d34f36ab35127b29ab583fa14ec618e5ae
http://xiangce.baidu.com/picture/album/list/f804e84d4e5b9dd3c38f99aa0ecd6a23836c5c40
http://xiangce.baidu.com/picture/album/list/4849aa5a98dfd63d1156324e4d08016a103f03ae
http://xiangce.baidu.com/picture/album/list/156e6a3419b2244cbab37b0fde86e23bb4567c40
http://xiangce.baidu.com/picture/album/list/6e7fa02d47dfe7d3f86ef60f604402c2033323ae
eee4444
老式的不行,新近出的應該可以。祝你好運!
eee4444
具體我還真的不太懂,太不好意思啦
原創(chuàng)文章,作者:九賢生活小編,如若轉(zhuǎn)載,請注明出處:http://xiesong.cn/28640.html