Re: [問題] 請問java有像asp的dictionary這樣的東西
再次謝謝PsMonkey的回覆.
我有找到一個範例
http://inonat.blogspot.tw/2011/04/java-hashmap.html
但有個問題, 範例 HashMap < Name, LinkedList < NameDistancePair > > 裡,
沒有教怎麼讀出資料, 請問該怎麼讀出資料呢?
這裡put資料的語法
HashMap<Name, LinkedList<NameDistanePair>> test=new HashMap(11);
LinkedList cs=new LinkedList<NameDistanePair>();
cs.add(new NameDistanePair("LS",7));
cs.add(new NameDistanePair("CL",20));
test.put(new Name("CS"),cs);
該怎麼get 呢?
請大大解惑~~萬分感激
※ 引述《PsMonkey (痞子軍團團長)》之銘言:
: ※ 引述《smsim (crazyM)》之銘言:
: : 請問java有像asp的dictionary 這樣的 object嗎?
: : 比如, 學生的各科成績存在object後, 可以用學生的id去取得各科成績.
: : studentScore("123456").mathScore
: : studentScore("123456").artScore
: : studentScore("456789").mathScore
: : studentScore("456789").artScore
: : "123456", "456789" 是代表二個學生的id
: : 我想應該是有的, 只是我不知道用什麼關鍵字去找相關的範例來參考. 請大大指點迷津~~
: ==.==== 麻煩也請你介紹 ASP 的 dictionary 介紹的詳細一點
: 不然 code 也給完整一點....
: 我猜我的 code 大概跟 dictionary 的功能扯不上關係
: 不過能完全符合你的需求
: class Student {
: public int mathScore;
: public int artScore;
: public String id;
: }
: Hashmap<String, Student> hash = new Hashmap<String, Student>();
: hash.put(studentA.id, studentA);
: ====
: 算了,還是統統鎖起來好了 [龐統配音]
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.220.203.115
→
03/12 12:43, , 1F
03/12 12:43, 1F
→
03/12 12:57, , 2F
03/12 12:57, 2F
→
03/12 13:13, , 3F
03/12 13:13, 3F
→
03/12 13:14, , 4F
03/12 13:14, 4F
→
03/12 14:00, , 5F
03/12 14:00, 5F
→
03/12 14:27, , 6F
03/12 14:27, 6F
→
03/12 14:37, , 7F
03/12 14:37, 7F
→
03/12 14:42, , 8F
03/12 14:42, 8F
推
03/12 15:30, , 9F
03/12 15:30, 9F
→
03/13 16:05, , 10F
03/13 16:05, 10F
→
03/13 16:07, , 11F
03/13 16:07, 11F
討論串 (同標題文章)