一定期間更新がないため広告を表示しています
マップ(TreeMap)
- 2006.08.08 Tuesday
- コレクション(リスト、セット)とマップ
- 21:33
- comments(0)
- trackbacks(0)
- by javaget
TreeMap も HashMap と同じように使用できます。要素がキーによって自動的にソートされる点が HashMap と異なります。
§TreeMapTest.java
import java.util.*;
class TreeMapTest {
public static void main(String[] args) {
TreeMap map = new TreeMap();
map.put("Name", "Tanaka");
map.put("Age", new Integer(26));
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object o = it.next();
System.out.println(o + " = " + map.get(o));
}
}
}
§TreeMapTest.java
import java.util.*;
class TreeMapTest {
public static void main(String[] args) {
TreeMap map = new TreeMap();
map.put("Name", "Tanaka");
map.put("Age", new Integer(26));
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object o = it.next();
System.out.println(o + " = " + map.get(o));
}
}
}
- コメント
- コメントする
- この記事のトラックバックURL
- トラックバック
- selected entries
-
- マップ(TreeMap) (08/08)
- categories
- archives
-
- August 2006 (88)
- profile
- search this site.
- mobile
-
- calendar
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
- sponsored links