1.values()返回的是 V 值集合,是一個 list 集合對象;keySet()返回的是 K 值集合,是
一個 Set 集合對象;entrySet()返回的是 K-V 值組合集合。
entrySet()使用:
某個集合為entrySet
//將關系集合entrySet進行迭代,存放到迭代器中
Iterator<Map.Entry<String, String>> it2 = entrySet.iterator();
再遍歷該迭代器:
while(it2.hasNext()){
Map.Entry<String, String> me = it2.next();//獲取Map.Entry關系對象me
String key2 = me.getKey();//通過關系對象獲取key
String value2 = me.getValue();//通過關系對象獲取value
System.out.println("key: "+key2+"-->value: "+value2);
}
2.調用其他接口post請求時,傳入的參數(shù)使用對象object的模式,不要傳入一個拼接各個參數(shù)的字符串(會有轉義的問題,易出錯)
3.獲取當前毫秒數(shù) System.currentTimeMillis()
4.finally 塊必須對資源對象、流對象進行關閉,有異常也要做 try-catch。
不能在 finally 塊中使用 return,finally 塊中的 return 返回后方法結束執(zhí)行,不
會再執(zhí)行 try 塊中的 return 語句。
5.字符串補齊空格,如補齊到20位:StringUtils.rightPad()
有右補齊和左補齊