标签:int [] tree 对象 数据 ext table 大小 collect
1. map
1.1. map中的方法
wpsB935.tmp
1.2. Map.Entry
对于集合来讲,就是把kye-value的数据保存在了Map.Entry的实例之后,再在Map集合中插入了一个Map.Entry的实例化对象
Map.Entry一般用于输出集合
wpsB946.tmpwpsB947.tmp
wpsB948.tmp
1.3. Map接口的常用子类
wpsB959.tmp
1.4. HashTable和HashMap区别
wpsB95A.tmp
1.5. Map的标准输出(2个)
方案一:
wpsB95B.tmp
方案二:
wpsB96B.tmp=package com.ftl;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class map {
public static void main(String[] args){
Map<String,String>map = new TreeMap<>();
map.put("Hello", "world");
map.put("Hello1", "world1");
map.put("Hello2", "world2");
map.put("Hello3", "world3");
String str = map.get("Hello");
Set<String> set = map.keySet();
Collection<String> values = map.values();
Iterator<String> iterator = set.iterator();
Iterator<String> iter = values.iterator();
System.out.println("\nforeach方法:");
for (String s : values) {
System.out.print(s+"、");
}
System.out.println("\nIterator方法:");
while(iterator.hasNext()){
System.out.print(iterator.next()+"、");
}
System.out.println("\nMap的标准输出_1(Map.entrySet):");
Set<Entry<String,String>> entrySet = map.entrySet();
Iterator<Map.Entry<String, String>> it = entrySet.iterator();
while(it.hasNext()){
Map.Entry<String, String> next = it.next();
System.out.print(next.getKey()+"-->: "+next.getValue()+"\n");
}
System.out.println("\nMap的标准输出_2(Foreach):");
for (Map.Entry<String, String> entry : entrySet) {
System.out.print(entry.getKey()+"-->: "+entry.getValue()+"\n");
}
System.out.println("Map.entrySet()大小:"+map.entrySet().size());
}
}
1.6. 人员配置
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class map {
public static void main(String[] args){
Map<String,String>map = new TreeMap<>();
map.put("Hello", "world");
map.put("Hello1", "world1");
map.put("Hello2", "world2");
map.put("Hello3", "world3");
String str = map.get("Hello");
Set<String> set = map.keySet();
Collection<String> values = map.values();
Iterator<String> iterator = set.iterator();
Iterator<String> iter = values.iterator();
System.out.println("\nforeach方法:");
for (String s : values) {
System.out.print(s+"、");
}
System.out.println("\nIterator方法:");
while(iterator.hasNext()){
System.out.print(iterator.next()+"、");
}
System.out.println("\nMap的标准输出_1(Map.entrySet):");
Set<Entry<String,String>> entrySet = map.entrySet();
Iterator<Map.Entry<String, String>> it = entrySet.iterator();
while(it.hasNext()){
Map.Entry<String, String> next = it.next();
System.out.print(next.getKey()+"-->: "+next.getValue()+"\n");
}
System.out.println("\nMap的标准输出_2(Foreach):");
for (Map.Entry<String, String> entry : entrySet) {
System.out.print(entry.getKey()+"-->: "+entry.getValue()+"\n");
}
System.out.println("Map.entrySet()大小:"+map.entrySet().size());
}
}
标签:int [] tree 对象 数据 ext table 大小 collect
原文地址:https://www.cnblogs.com/ftl1012/p/9216936.html