put(K key, V value):V
size():int
remove(Object key):V
remove(Object key, Object value):boolean
replace(K key, V value):default V
replace(K key, V oldValue, V newValue):boolean
// TreeMap
//
System.out.println("=====TreeMap=====");
// TreeMap<String,pModelVo03> tm = new TreeMap<>();
TreeMap<String,pModelVo03> tm = new TreeMap<>(hm);
System.out.println(tm); // {내=으샤으샤[2원], 라=으랴차차[3원], 힘=아자아자[1원]}
// size():int
System.out.println(tm.size()); // 3
// remove(Object key):V
// System.out.println(tm.remove(new TreeMap("힘"), new TreeMap("아자아자",1)));
System.out.println(tm.remove(new String("힘"))); // value리턴 : 아자아자[1원]
System.out.println(tm); // {내=으샤으샤[2원], 라=으랴차차[3원]}
System.out.println(tm.keySet());
Set<String> set = tm.keySet();
Iterator<String> itr = set.iterator();
while(itr.hasNext()) {
String str = itr.next();
System.out.println(str);
}
System.out.println(tm.remove(new String("내")));
System.out.println(tm); // {라=으랴차차[3원]}
System.out.println("===replace===");
// replace(K key, V oldValue, V newValue):boolean
System.out.println(tm.replace(new String("라"), new pModelVo03("으랴차차",3), new pModelVo03("화이팅",4)));//true
// remove(Object key, Object value):boolean
tm.remove(new String("라"), new pModelVo03("화이팅",4));
System.out.println(tm); // {}
System.out.println("===TreeMap2===");
TreeMap<String,pModelVo03> tm2 = new TreeMap<>();
// put(K key, V value):V
tm2.put(new String("a"), new pModelVo03("a",1));
tm2.put(new String("b"),new pModelVo03("b",2));
tm2.put(new String("c"),new pModelVo03("c",3));
System.out.println(tm2); // {a=a[1원], b=b[2원], c=c[3원]}
// size():int
System.out.println(tm2.size()); // 2
// remove(Object key):V
System.out.println(tm2.remove(new String("b"))); // 지운 밸류값 출력 : b[2원]
System.out.println(tm2); // {a=a[1원], c=c[3원]}
// remove(Object key, Object value):boolean
System.out.println(tm2.remove(new String("a"),new pModelVo03("a",1)));// true
System.out.println(tm2); // {c=c[3원]}
// replace(K key, V value):default V
System.out.println(tm2.replace(new String("c"), new pModelVo03("c",3))); // c[3원]
// replace(K key, V oldValue, V newValue):boolean
tm2.replace(new String("c"), new pModelVo03("c",3), new pModelVo03("d",4));
System.out.println(tm2.replace(new String("c"), new pModelVo03("c",3), new pModelVo03("d",4)));//false
System.out.println(tm2); // {c=d[4원]} : 키값c 밸류값d,4