Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java HashMapºÍTreeMapµÄÅÅÐòÎÊÌâ×ܽá

Map´æ´¢µÄÊÇkey->valueµÄÖµ¶Ô£¬keyµÄÖµÊÇΨһµÄ£¬¶øvalueµÄÖµ¿ÉÒÔÖظ´¡£Í¨³£Ê¹ÓõÄÊÇHashMap»òTreeMap£¬Èç¹û¿¼ÂÇÐÔÄÜ£¬Ê¹ÓÃHashMap¡£TreeMapʹÓúìºÚÊ÷ʵÏÖ£¬±£ÁôÓÐkeyֵ˳ÐòÐÔ£¬»á×Ô¶¯°´ÕÕkeyÖµÅÅÐò¡£
ĬÈÏÊÇ°´ÕÕkeyÖµµÄÉýÐòÅÅÐò£¬keyÖµ±ØÐëʵÏÖ Comparator½Ó¿Ú¡£Èç¹ûÏ£Íû°´ÕÒÒ»¶¨¹æÔòÅÅÐò£¬ÔòÐèÒªÖØж¨Òåcompareº¯Êý¡£
Èç:
TreeMap hm = new TreeMap<String, String>(new Comparator() {
public int compare(Object o1, Object o2) {
//Èç¹ûÓпÕÖµ£¬Ö±½Ó·µ»Ø0
if (o1 == null || o2 == null)
return 0;

return String.valueOf(o1).compareTo(String.valueOf(o2));
}
});  
¶ÔÓÚ´¦ÀíÓÐÖÐÎÄÅÅÐòµÄÎÊÌâ 
TreeMap hm = new TreeMap<String, String>(new Comparator() {
public int compare(Object o1, Object o2) {
//Èç¹ûÓпÕÖµ£¬Ö±½Ó·µ»Ø0
if (o1 == null || o2 == null)
return 0;

CollationKey ck1 = collator.getCollationKey(String.valueOf(o1));
CollationKey ck2 = collator.getCollationKey(String.valueOf(o2));
return ck1.compareTo(ck2);
}
});
 
±¸×¢£º CollationKey£ºCollationKey ±íʾ×ñÊØÌض¨ Collator ¶ÔÏó¹æÔòµÄ String¡£
±È½ÏÁ½¸öCollationKey ½«·µ»ØËüÃÇËù±íʾµÄ String µÄÏà¶Ô˳Ðò¡£Ê¹Óà CollationKey À´±È½Ï String ͨ³£±ÈʹÓà Collator.compare ¸ü¿ì¡£Òò´Ë£¬µ±±ØÐë¶à´Î±È½Ï String ʱ £¨ÀýÈ磬¶ÔÒ»¸ö String Áбí½øÐÐÅÅÐò£©£¬Ê¹Óà CollationKey »á¸ü¸ßЧ¡£
Èç¹ûÏë°´ÕÕvalueÅÅÐò»òÕßÊǶÔHashMapÖеÄkey»òvalueÅÅÐòÔò¿ÉÒÔÈçÏ£º
List<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(m.entrySet());
Collections.sort(list,new Comparator<Map.Entry<String,Integer>>(){
public int compare(Map.Entry<String,Integer> o1, Map.Entry<String,Integer> o2){
return o2.getValue()-o1.getValue();
}
});&


Ïà¹ØÎĵµ£º

Java NIO APIÏê½â

 
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......

java stringÀàÏê½â

Java×Ö·û´®Àà(java.lang.String)ÊÇJavaÖÐʹÓÃ×î¶àµÄÀ࣬ҲÊÇ×îΪÌØÊâµÄÒ»¸öÀ࣬ºÜ¶àʱºò£¬ÎÒÃǶÔËü¼ÈÊìϤÓÖÄ°Éú¡£
 
Ò»¡¢´Ó¸ù±¾ÉÏÈÏʶjava.lang.StringÀàºÍString³Ø
 
Ê×ÏÈ£¬ÎÒ½¨ÒéÏÈ¿´¿´StringÀàµÄÔ´ÂëʵÏÖ£¬ÕâÊÇ´Ó±¾ÖÊÉÏÈÏʶStringÀàµÄ¸ù±¾³ö·¢µã¡£´ÓÖпÉÒÔ¿´µ½£º
1¡¢StringÀàÊÇfinalµÄ£¬²»¿É±»¼Ì³Ð¡£publ ......

Java BeanÔ­ÀíÓëÓ¦ÓÃ

   ¡¡¡¡1¡¢Ê²Ã´ÊÇJavaBean£¿  
   
  ¡¡¡¡JavaBeanÊÇÃèÊöJavaµÄÈí¼þ×é¼þÄ£ÐÍ£¬ÓеãÀàËÆÓÚMicrosoftµÄCOM×é¼þ¸ÅÄî¡£ÔÚJavaÄ£ÐÍÖУ¬Í¨¹ýJavaBean¿ÉÒÔÎÞÏÞÀ©³äJava³ÌÐòµÄ¹¦ÄÜ£¬Í¨¹ýJavaBeanµÄ×éºÏ¿ÉÒÔ¿ìËÙµÄÉú³ÉеÄÓ¦ÓóÌÐò¡£¶ÔÓÚ³ÌÐòÔ±À´Ëµ£¬×îºÃµÄÒ»µã¾ÍÊÇJavaBean¿ÉÒÔʵÏÖ´úÂëµÄÖظ´ÀûÓ ......

JavaλËãÊõÔËËã·û

 
1£©&£ºÓëÔËË㣬½«Á½¸öÊý·Ö±ðת»¯³É²¹Â룬Ȼºó½øÐÐÔËË㣨ȫ1µÃ1£¬ÓÐ0³ö0£©¡£
2£©£¡£º·ÇÔËË㣬½«Êý×Ö×ÔÉíÈ¡·´£¨×ª»¯³É²¹Â룬°´Î»È¡·´——1±ä0£¬0±ä1£©¡£
3£©<<£º×óÒÆÔËËã·û£¬½«Ä³¸öÊ®½øÖÆת»»³É¶þ½øÖÆÖ®ºóĩβµÄn¸ö¶þ½øÖÆÊýÒÔ´ËÍù×óÒƶ¯£¬Òç³öµÄnλÓÃ0ÔÚĩβ²¹×ã¡£
4£©>>£º´ø·ûºÅÓÒÒÆÔË ......

java date

//¼òµ¥µÄjavaÈÕÆÚ¸ñʽ¿ØÖÆ
 java.Text.SimpleDateFormat format = new java.Text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//ÄãÏëÒªµÄ¸ñʽ
//×¢ÒâÔµÄλÖÃÒª´óдµÄMM  Òª²»¾Í¿´µ½µÄ²»ÊÇÕýÈ·ÏÔʾ£¬¿ÉÒÔ°ÑÄãÏëҪת»»µÄÈÕÆÚת»»ÎªÏàÓ¦µÄ¸ñʽ°¡
format.format(new java.util.Date());//dateΪÈÕÆÚÐÍÊý¾Ý£¬¿ÉÒÔÈÎÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ