JavaµÄÈÝÆ÷ÀàVector¡¢ArrayList¡¢HashTableµÈ
ÏßÐÔ±í£¬Á´±í£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹£¬ÔÚ½øÐÐJava¿ª·¢Ê±£¬JDKÒѾΪÎÒÃÇÌṩÁËһϵÁÐÏàÓ¦µÄÀàÀ´ÊµÏÖ»ù±¾µÄÊý¾Ý½á¹¹¡£ÕâЩÀà¾ùÔÚjava.util°üÖС£±¾ÎÄÊÔͼͨ¹ý¼òµ¥µÄÃèÊö£¬Ïò¶ÁÕß²ûÊö¸÷¸öÀàµÄ×÷ÓÃÒÔ¼°ÈçºÎÕýȷʹÓÃÕâЩÀà¡£
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£¬Ôò±ØÐ
Ïà¹ØÎĵµ£º
package org.mingyuan.fetcher;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
i ......
java»Øµ÷»úÖÆ
»Øµ÷¸ÅÄî:
Èí¼þÄ£¿éÖ®¼ä×ÜÊÇ´æÔÚ×ÅÒ»¶¨µÄ½Ó¿Ú£¬´Óµ÷Ó÷½Ê½ÉÏ£¬¿ÉÒÔ°ÑËûÃÇ·ÖΪÈýÀࣺͬ²½µ÷Óᢻص÷ºÍÒì²½µ÷Óá£Í¬²½µ÷ÓÃÊÇÒ»ÖÖ×èÈûʽµ÷Ó㬵÷Ó÷½ÒªµÈ´ý¶Ô·½Ö´ÐÐÍê±Ï²Å·µ»Ø£¬ËüÊÇÒ»ÖÖµ¥Ïòµ÷Ó㻻ص÷ÊÇÒ»ÖÖË«Ïòµ÷ÓÃģʽ£¬Ò²¾ÍÊÇ˵£¬±»µ÷Ó÷½ÔÚ½Ó¿Ú±»µ÷ÓÃʱҲ»áµ÷ÓöԷ½µÄ½Ó¿Ú£»Òì²½µ÷ÓÃÊÇÒ»ÖÖÀàËÆ ......
±ÈÈçjavaÖг£ÓõÄÔËËã·û
Ò» ·ûºÅ++ ,+,--,-
ÓÐʱÕâ¸ö·ûºÅÆ´´ÕÆðÀ´Ò²Óе㸴ÔÓ
±ÈÈçÕâÑùÒ»¸öÔËËãʽ
int i=3;
i+++i-i++-++i
+ -ÔËËã·ûµÄÓÅÏȼ¶ µÍÓÚ++£¬-- ÏÈÔËËã++£¬--
¿ÉÒÔ½«ÉÏÃæµÄʽ×Ó²ð¿ª
i++ + i - i++ - ++i
ÕâÑùÊDz»ÊÇÈÝÒ׶àÁË
ÏÈÀ´¸ö¼òµ¥µãµÄ
1 K++
int k=0;
System.out.println(K++)
System.o ......
ÏÂÃ濪½²¹ÊÊ£º
´ÓÇ°Óиö·¿¼ä£¬·¿¼äÀïÓзÝÎĵµ£¬·¿¼ä»¹ÓÐÒ»°ÑÔ¿³×¡£ Õâ°ÑÔ¿³×ÔÚÕÅÈýÊÖÀï¡£
ÕâʱÀîËÄÀ´ÏòÕÅÈýÒªÄÇ·ÝÎĵµ¡£ ÕÅÈý²»Ì«Ï²»¶ÀîËÄ£¬µ«ÓÖŵ¢ÎóÁË
¹¤×÷²»ºÃ½»´ú¡£ÓÚÊÇÕÅÈý¾Í°Ñ·¿¼äÀïÎĵµµÄÎĵµ¸´Ó¡ÁËÒ»·Ý£¬È»ºó°ÑÄǸö¸´Ó¡¼þ½»¸øÁËÀîËÄ£¨Õâ½Ð´«Öµ£©¡£
ÀîËÄÄõ½Îĵµºó£¨¸´Ó¡¼þ£©£¬ºúÂÒÐÞ¸ÄÒ» ......
package thread;
class TestThread extends Thread {
public void run(){
while(true){
System.out.println(Thread.currentThread().getName());
}
}
}
public class ThreadDemo {
/**
* @param args
*/
public static void ......