????33????????????????????????????????????????.toString()????????String.valueOf(????)?????????+”"??
???????????????????????????????????????????Integer??????i?????????i.toString()??String.valueOf(i)??i+”"????????????????Ч????Σ???????????
????public static void main(String[] args)
????{
????int loopTime = 50000;
????Integer i = 0; long startTime = System.currentTimeMillis(); for (int j = 0; j < loopTime; j++)
????{
????String str = String.valueOf(i);
????}
????System.out.println("String.valueOf()??" + (System.currentTimeMillis() - startTime) + "ms");
????startTime = System.currentTimeMillis(); for (int j = 0; j < loopTime; j++)
????{
????String str = i.toString();
????}
????System.out.println("Integer.toString()??" + (System.currentTimeMillis() - startTime) + "ms");
????startTime = System.currentTimeMillis(); for (int j = 0; j < loopTime; j++)
????{
????String str = i + "";
????}
????System.out.println("i + ""??" + (System.currentTimeMillis() - startTime) + "ms");
????}
???????н?????
????String.valueOf()??11ms Integer.toString()??5ms i + ""??25ms
??????????????????????????????????String???????????????toString()????????????????????
????1??String.valueOf()????????????Integer.toString()??????????????????????ж?
????2??Integer.toString()??????????????????
????3??i + “”????????StringBuilder????????append????????????toString()????????????
??????????????????????2??1?????3??
????34???????Ч??????????Map
????????Map?????к?????????????????????????Map?е?Key??Value?????????????Ч?????????
????public static void main(String[] args)
????{
????HashMap<String?? String> hm = new HashMap<String?? String>();
????hm.put("111"?? "222");
????Set<Map.Entry<String?? String>> entrySet = hm.entrySet();
????Iterator<Map.Entry<String?? String>> iter = entrySet.iterator(); while (iter.hasNext())
????{
????Map.Entry<String?? String> entry = iter.next();
????System.out.println(entry.getKey() + " " + entry.getValue());
????}
????}
???????????????????????Map??key???????”Set<String> keySet = hm.keySet();”????????Щ
????35?????????close()??????????
???????????????????????δ???
????try{
????XXX.close();
????YYY.close();
????}catch (Exception e)
????{
????...
????}
??????????????
????try{ XXX.close(); }catch (Exception e) { ... }try{ YYY.close(); }catch (Exception e) { ... }
?????????Щ?鷳???????????й???????????????????????????XXX.close()????????????????cath???????YYY.close()??????У?YYY???????????????????????????????????????????????????й??????????????д?????????????????XXX??YYY????close???