import java.util.*;输出:
public class Recherche_valeur_treemap {
public static void main(String[] args) {
// 创建 TreeMap
TreeMap<字符串,字符串>treemap = 新树图<字符串,字符串>();
// 插入到 treemap
treemap.put(1”, a”);
treemap.put(2”, b”);
treemap.put(3”, c”);
treemap.put(4”, d”);
treemap.put(5”, e”);
//显示关键元素和值
Set set=treemap.keySet();
迭代器 迭代器 = set.iterator();
while(iterator.hasNext()){
String key = ((String) iterator.next());
字符串 val = ((String) treemap.get(key));
System.out.println(键+->+val);
}
布尔值存在 = treemap.containsValue(a”);
System.out.println(值 a 存在于列表中:”+exists);
exists = treemap.containsValue(f”);
System.out.println(列表中存在 f 值:”+存在);
}
}
1->aReferences:
2->b
3->c
4->d
5->e
列表中存在 a 值:true
列表中存在 f 值:false
Please disable your ad blocker and refresh the window to use this website.