JAVAµÄÈÝÆ÷
JAVAµÄÈÝÆ÷---List,Map,Set
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð© CollectionÔÊÐíÏàͬµÄÔªËضøÁíһЩ²»ÐС£Ò»Ð©ÄÜÅÅÐò¶øÁíһЩ²»ÐС£Java SDK²»Ìṩֱ½Ó¼Ì³Ð×ÔCollectionµÄÀ࣬Java SDKÌṩµÄÀ඼ÊǼ̳Ð×ÔCollectionµÄ“×Ó½Ó¿Ú”ÈçListºÍSet¡£
¡¡¡¡ËùÓÐʵÏÖCollection½Ó¿ÚµÄÀ඼±ØÐëÌṩÁ½¸ö±ê×¼µÄ¹¹Ô캯Êý£ºÎÞ²ÎÊýµÄ¹¹Ô캯ÊýÓÃÓÚ´´½¨Ò»¸ö¿ÕµÄCollection£¬ÓÐÒ»¸ö Collection²ÎÊýµÄ¹¹Ô캯ÊýÓÃÓÚ´´½¨Ò»¸öеÄCollection£¬Õâ¸öеÄCollectionÓë´«ÈëµÄCollectionÓÐÏàͬµÄÔªËØ¡£ºóÒ»¸ö¹¹Ô캯ÊýÔÊÐíÓû§¸´ÖÆÒ»¸öCollection¡£
¡¡¡¡ÈçºÎ±éÀúCollectionÖеÄÿһ¸öÔªËØ£¿²»ÂÛCollectionµÄʵ¼ÊÀàÐÍÈçºÎ£¬Ëü¶¼Ö§³ÖÒ»¸öiterator()µÄ·½·¨£¬¸Ã·½·¨·µ»ØÒ»¸öµü´ú×Ó£¬Ê¹Óøõü´ú×Ó¼´¿ÉÖðÒ»·ÃÎÊCollectionÖÐÿһ¸öÔªËØ¡£µäÐ͵ÄÓ÷¨ÈçÏ£º
¡¡¡¡¡¡¡¡Iterator it = collection.iterator(); // »ñµÃÒ»¸öµü´ú×Ó
¡¡¡¡¡¡¡¡while(it.hasNext()) {
¡¡¡¡¡¡¡¡¡¡¡¡Object obj = it.next(); // µÃµ½ÏÂÒ»¸öÔªËØ
¡¡¡¡¡¡¡¡}
¡¡¡¡ÓÉCollection½Ó¿ÚÅÉÉúµÄÁ½¸ö½Ó¿ÚÊÇListºÍSet¡£
List½Ó¿Ú
¡¡¡¡ListÊÇÓÐÐòµÄCollection£¬Ê¹Óô˽ӿÚÄܹ»¾«È·µÄ¿ØÖÆÿ¸öÔªËزåÈëµÄλÖá£Óû§Äܹ»Ê¹ÓÃË÷Òý£¨ÔªËØÔÚListÖеÄλÖã¬ÀàËÆÓÚÊý×éϱ꣩À´·ÃÎÊListÖеÄÔªËØ£¬ÕâÀàËÆÓÚJavaµÄÊý×é¡£
ºÍÏÂÃæÒªÌáµ½µÄSet²»Í¬£¬ListÔÊÐíÓÐÏàͬµÄÔªËØ¡£
¡¡¡¡³ýÁ˾ßÓÐCollection½Ó¿Ú±Ø±¸µÄiterator()·½·¨Í⣬List»¹Ìṩһ¸ölistIterator()·½·¨£¬·µ»ØÒ»¸ö ListIterator½Ó¿Ú£¬ºÍ±ê×¼µÄIterator½Ó¿ÚÏà±È£¬ListIterator¶àÁËһЩadd()Ö®ÀàµÄ·½·¨£¬ÔÊÐíÌí¼Ó£¬É¾³ý£¬É趨ԪËØ£¬»¹ÄÜÏòÇ°»òÏòºó±éÀú¡£
¡¡¡¡ÊµÏÖList½Ó¿ÚµÄ³£ÓÃÀàÓÐLinkedList£¬ArrayList£¬VectorºÍStack¡£
LinkedListÀà
¡¡¡¡LinkedListʵÏÖÁËList½Ó¿Ú£¬ÔÊÐínullÔªËØ¡£´ËÍâLinkedListÌṩ¶îÍâµÄget£¬remove£¬insert·½·¨ÔÚ LinkedListµÄÊײ¿»òβ²¿¡£ÕâЩ²Ù×÷ʹLinkedList¿É±»ÓÃ×÷¶ÑÕ»£¨stack£©£¬¶ÓÁУ¨queue£©»òË«Ïò¶ÓÁУ¨deque£©¡£
¡¡¡¡×¢ÒâLinkedListûÓÐͬ²½·½·¨¡£Èç¹û¶à¸öÏß³Ìͬʱ·ÃÎÊÒ»¸öList£¬Ôò±ØÐë×Ô¼ºÊµÏÖ·ÃÎÊͬ²½¡£Ò»ÖÖ½â¾ö·½·¨ÊÇÔÚ´´½¨Listʱ¹¹ÔìÒ»¸öͬ²½µÄList£º
¡¡¡¡¡¡¡¡List l
Ïà¹ØÎĵµ£º
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
1Calendar time=Calendar.getInstance();
2time.clear();
3time.set(Calendar.YEAR,year); //year Ϊ int
4time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
5int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);//±¾Ô·ݵÄÌìÊý
×¢£ºÔÚʹÓÃset·½·¨Ö®Ç°£¬±ØÐë ......
¾àÀëJava7µÄMR°æ±¾·¢²¼ÓжÎʱ¼äÁË£¬Í¨¹ý°²×°ÊÔÓÃÖ®ºóµÄ×ÜÌå¸Ð¾õÊÇ£ºËÙ¶ÈÓÖ¿ìÁË¡£×ÐϸÔĶÁÁËJava7µÄÏà¹ØÎĵµ·¢ÏÖ£¬Java7ÓµÓÐÈçϵÄһЩеÄÌØÐÔ¡£
Ê×ÏÈÊÇÄ£¿é»¯ÌØÐÔ£¬Èç¹ûÄú°²×°ºÍʹÓùýNetBeans6.7µÄ»°£¬ÊDz»ÊÇ»áÓÐÒ»¸öºÜ´óµÄ¸Ð¾õ£¬¾ÍÊÇNetBeans6.7µÄÆô¶¯ËٶȱÈÒÔÇ°¿ìÁ˺ܶ࣬µ±È»²¢²»ÊÇNetBeansÒѾʹ ......
¶ÔÓÚÔÓïÀàÐ͵ÄÊý×飬Èçint[] a,ÔÚCÀïÃæÖ»ÒªÕâÑù¶¨ÒåÖ®ºó¾Í¿ÉÒÔÓÃa[i]ʹÓÃÁË£¬µ«ÊÇÔÚJAVAÀïÃæÊDz»Ðеģ¬±ØÐëÓÃint[] a = new int[LENGTH];À´ÎªÊý×é·ÖÅä¿Õ¼ä¡£ÕâÀïµÄa¸üÓ¦¸Ã¿´³ÉCÀïÃæµÄÖ¸Õ룬ËüºÍCÀïÃæµÄint* aÊÇÒ»ÑùµÄ£¬ÒòΪÕâ¸öa£¨CÀïÃæµÄ£©Ò²ÒªÏÈmallocÒ»¸ö¿Õ¼äÖ®ºó²Å¿ ......
javeÔõôѧϰ×î¿ì
2008-11-08 06:57
ÓûËÙÔò²»´ï£¬Ñ§Ï°JAVAûÓГ¿ÉÒÔÀ”ÕâÖ̶ֳȡ£·á¸»¶à²Ê£¬Ñ§Ï°Ò»ÄêµÄʱ¼äÒ²²»Ò»¶¨ÄÜѧÍê»ù´¡£¬ÎÒÔø¾Ò²Ïë¹ýÕâ¸öÎÊÌ⣬µ«ºóÀ´¿´ÁËһƪÎÄÕ£¬±ã³¹È»ÐÑÎò¡£ÏÂÃæÕâƪÎÄÕ£¨²»ÒªÏÓ³¤£¬¿´Íê¾ÍÓÐÊÕÒ棬»¹ÓдËÎÊÌâ²»Òª¹Ø±Õ»òÊÇͶƱ£¬»Ø´ð¶¼ÊÇÐÁ¿àµØ£¬²»Òª´ò»ý¼«ÐÔ£¬²»¹»ºÃÒ²½«¾ÍЩ°É ......