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
Ïà¹ØÎĵµ£º
½ñÌìÓöµ½ÁËÕâ¸öÎÊÌâ ÁËºÇºÇ ½â¾öÁ˸ø´ó¼Ò·ÖÏíÏÈ£¬java.lang.OutOfMemoryError: Java heap space ÒýÆðÁËÎÒÉÏ´«³ö´í¡£ÎÒ½â¾ö°ì·¨¾ÍÊÇ¿´ÄãʹÓõÄtomcat·þÎñÆ÷°æ±¾ÊÇʲôÑùµÄ£¬Èç¹ûÄãµÄtomcat/binϱßÓÐtomcatw.exe ¾Í·½±ãÁË£¬Ö±½Ó¿ÉÊÓ»¯²Ù×÷ŶÏÂÏÂͼ
ÆäÖÐÉèÖóõʼÄÚ´æ³ØºÍ×î´óÄÚ´æ³Ø£¬ÉèÖÃÔÔòÊǸù¾ÝÄãµÄÎïÀíÄÚ´æÀ´¶¨¡£
Èç¹û ......
[ת]Java´òÓ¡³ÌÐòÉè¼ÆÈ«¹¥ÂÔ
2008-12-07 18:43
Ç°ÑÔ
¡¡¡¡ÔÚÎÒÃǵÄʵ¼Ê¹¤×÷ÖУ¬¾³£ÐèҪʵÏÖ´òÓ¡¹¦ÄÜ¡£µ«ÓÉÓÚÀúÊ·ÔÒò£¬JavaÌṩµÄ´òÓ¡¹¦ÄÜÒ»Ö±¶¼±È½ÏÈõ¡£Êµ¼ÊÉÏ×î³õµÄjdk¸ù±¾²»Ö§³Ö´òÓ¡£¬Ö±µ½jdk1.1²ÅÒýÈëÁ˺ÜÇáÁ¿µÄ´òÓ¡Ö§³Ö¡£ËùÒÔ£¬ÔÚÒÔÇ°ÓÃJava/Applet/JSP/ServletÉè¼ÆµÄ³ÌÐòÖУ¬½Ï¸´ÔӵĴòÓ¡¶¼ÊÇͨ¹ýµ÷ÓÃActiveX/OCX¿ ......
Javaµ÷Óô洢¹ý³Ì
±¾ÎIJûÊöÁËÔõôʹÓÃDBMS´æ´¢¹ý³Ì¡£ÎÒ²ûÊöÁËʹÓô洢¹ý³ÌµÄ»ù±¾µÄºÍ¸ß¼¶ÌØÐÔ£¬±ÈÈç·µ»ØResultSet¡£±¾ÎļÙÉèÄã¶ÔDBMSºÍJDBCÒѾ·Ç³£ÊìϤ£¬Ò²¼ÙÉèÄãÄܹ»ºÁÎÞÕÏ°µØÔĶÁÆäËüÓïÑÔд³ÉµÄ´úÂ루¼´²»ÊÇJavaµÄÓïÑÔ£©£¬µ«ÊÇ£¬²¢²»ÒªÇóÄãÓÐÈκδ洢¹ý³ÌµÄ±à³Ì¾Àú¡£
´æ´¢¹ý³ÌÊÇÖ¸±£´æÔÚ ......
1.µÃµ½µ±Ç°µÄʱ¼ä
Calendar cal = Calendar.getInstance();
String time=formatter.format(cal.getTime());
String strEnd=time.substring(0, 16);// 2007-10-30 09:30
Calendar cal = Calendar.getInstance();
String time=formatter.format(cal.getTime());
String strEnd=time.subst ......
¶ÔÓÚÔÓïÀàÐ͵ÄÊý×飬Èçint[] a,ÔÚCÀïÃæÖ»ÒªÕâÑù¶¨ÒåÖ®ºó¾Í¿ÉÒÔÓÃa[i]ʹÓÃÁË£¬µ«ÊÇÔÚJAVAÀïÃæÊDz»Ðеģ¬±ØÐëÓÃint[] a = new int[LENGTH];À´ÎªÊý×é·ÖÅä¿Õ¼ä¡£ÕâÀïµÄa¸üÓ¦¸Ã¿´³ÉCÀïÃæµÄÖ¸Õ룬ËüºÍCÀïÃæµÄint* aÊÇÒ»ÑùµÄ£¬ÒòΪÕâ¸öa£¨CÀïÃæµÄ£©Ò²ÒªÏÈmallocÒ»¸ö¿Õ¼äÖ®ºó²Å¿ ......