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

JavaÖÐHashMap£¬HashtableºÍLinkedList

½ñÌìÅöµ½Ò»¸öºÜÓÐÒâ˼µÄÎÊÌ⣬¾ÍÊǹØÓÚʹÓÃLinkedList×÷ΪHashMap»òÕßHashtableµÃkey£¬µ«ÊÇ×îºó·¢ÏÖÊý¾Ý²¢Ã»ÓÐ´æ½øÈ¥¡£
Ê×ÏÈ˵һÏÂHashMap£¬Hashtable°É£¬ËüÃǶ¼¼Ì³ÐÁËCloneable, Map, Serializable¡£ËüÃÇÁ½¸ö»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬“The HashMap
class is roughly equivalent to Hashtable
, except that it is
unsynchronized and permits nulls.”¡£Çø±ð¾ÍÊÇHashMapÔÊÐí“ null

values and the null

key”£¬Í¬Ê± unsynchronized¡£ËüµÄÐÔÄÜÈ¡¾öÓÚ“ initial capacity
and load factor
”£¬¾ßÌå²Î¿¼¹Ù·½Îĵµ¡£HashMap»¹ÓÐÒ»¸öÌØÐÔ¾ÍÊDz»Äܱ£Ö¤´æÈëµÄÔªËØµÄ˳Ðò£¬“HashMap does not guarantee that the order
will remain constant over time¡£” ¶ÔÓÚ´æÈëµ½ÀïÃæµÄkey£¬ÒªÇó“To successfully store and retrieve objects from a hashtable, the
objects used as keys must implement the hashCode

method and the equals
method. ”¡£¸ü¾ßÎҵIJâÊÔ£¬ÆäʵÕâ¸ö¶ÔÓÚHashMapÒ²ÊÇÊÊÓõġ£
Õâ¸ö¾ÍºÍÎÒ½ñÌìÅöµ½µÄÎÊÌâÁªÏµÉÏÁË£¬LinkedListÀàÀïÃæµÄhashCode()º¯ÊýÀ´Ô´ÓÚList.hashCode()£¬¾ßÌåÈçÏ£º
int hashCode = 1;
Iterator<E> i = list.iterator();
while (i.hasNext()) {
E obj = i.next();
hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
}
Ò²¾ÍÊÇ˵hashCodeÒÀÀµÓÚÄÚ²¿´æ´¢µÄ¶ÔÏó£¬Ç¡ºÃÎÒ´æ´¢µÄÊÇÒ»¸ö³éÏóÀ࣬ÒÔ·½±ãʵÏÖ¶à̬ÐÔ£¬ËùÒÔ²¢Ã»ÓÐʵÏÖhashCodeº¯Êý¡£Èç¹û´æ´¢µÄÊÇÀàËÆStringµÄ»ù±¾Êý¾ÝÀàÐÍ»òÕßÊÇʵÏÖÁËhashCodeº¯ÊýµÄ¶ÔÏó¾Í¿ÉÒÔÁË¡£
×îºó»¹ÓÐÒ»¸öºÍHashMapÓеãÈÝÒ×»ìÏýµÄÀà¾ÍÊÇTreeMap¡£Ëü¼Ì³ÐÁË“Serializable, Cloneable, Map<K,V>, SortedMap<K,V>”£¬ÊÇSortedMap½Ó¿ÚÀàΨһµÄʵÏÖ¡£Ëü±¾ÖÊÉÏÊÇ“Red-Black tree”£¬ÀïÃæ´æ´¢µÄkeyÊÇÉýÐòÅÅÁе쬓ascending key order”¡£
²Î¿¼£º
http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeMap.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/SortedMap.html


Ïà¹ØÎĵµ£º

JAVA¼òµ¥¸ÅÄî

1.ʵÀý³ÉÔ±ºÍÀà³ÉÔ±
ʵÀý³ÉÔ±ÖÐÊÇÊôÓÚ¶ÔÏóµÄ,°üÀ¨ÊµÀý³ÉÔ±±äÁ¿ºÍʵÀý³ÉÔ±·½·¨,Ö»Óд´½¨Á˶ÔÏóÖ®ºó²ÅÄÜ·ÃÎÊʵÀý³ÉÔ±±äÁ¿ºÍʵÀý³ÉÔ±·½·¨.
    Àà³ÉÔ±ÊÇÊôÓÚÀàµÄ,Àà³ÉÔ±ÐèÒªÓùؼü×Östatic±êʶ,Ò²³ÆÎª¾²Ì¬³ÉÔ±,Àà³ÉÔ±°üÀ¨Àà³ÉÔ±±äÁ¿ºÍÀà³ÉÔ±·½·¨,ͨ¹ýÀàÃû¿ÉÒÔÖ±½Ó·ÃÎÊÀà³ÉÔ±±äÁ¿ºÍµ÷ÓÃÀà³ÉÔ±·½·¨,¼´Ê¹Ã»Óд´½ ......

ÓÃJAVAʵÏÖ¶àỊ̈߳¨Éú²úÕßÓëÏû·ÑÕßÎÊÌ⣩


public class MultiThread {
 public static void main(String[] args) {
  ProductStack box = new ProductStack("box");
  Producer p1 = new Producer(box, "p1");
  Producer p2 = new Producer(box, "p2");
  Producer p3 = new Producer(box, "p3");
 &nb ......

PowerDesigner OOM Éú³ÉjavaÀà(Ò») ת javapark

×î½üÔÚʹÓÃPowerDesignerÉè¼ÆÊý¾Ý¿â,Éè¼ÆÍêcdm ºÍ pdmʱ,Á˽⵽¿ÉÒÔÓÃoom×Ô¶¯Éú³ÉJavaÀà.
    µ«ÊÇÉú³ÉµÄJavaÀàµÄĬÈϸñʽºÍ×Ô¼ºµÄÒªÇóÓÐÆ«²î,×îÖյõ½ÁËЩ½â¾ö°ì·¨.ÕâÀï¼Ç¼ÁËÏÂ.(ÎÒʹÓõİ汾ÊÇPowerDesigner12)
    ÔÚoomÄ£ÐÍÖÐlanguage>edit current object language. ÀàµÄÖ÷¸ñʽÊÇ ......

Java×¢Ê͹淶[×ªÔØ]

×¢Ê͵ÄÔ­Ôò
1¡¢ ×¢ÊÍÐÎʽͳһ
ÔÚÕû¸öÓ¦ÓóÌÐòÖУ¬Ê¹ÓþßÓÐÒ»ÖµıêµãºÍ½á¹¹µÄÑùʽÀ´¹¹Ôì×¢ÊÍ¡£Èç¹ûÔÚÆäËûÏîÄ¿×é·¢ÏÖËûÃǵÄ×¢Ê͹淶ÓëÕâ·ÝÎĵµ²»Í¬£¬°´ÕÕËûÃǵĹ淶д´úÂ룬²»ÒªÊÔͼÔڼȳɵĹ淶ϵͳÖÐÒýÈëеĹ淶¡£
2¡¢ ×¢Ê͵ļò½à
ÄÚÈÝÒª¼òµ¥¡¢Ã÷ÁË¡¢º¬Òå׼ȷ£¬·ÀÖ¹×¢Ê͵ĶàÒåÐÔ£¬´íÎóµÄ×¢ÊͲ»µ«ÎÞÒæ·´¶øÓÐ ......

Java°æµÄʵÏÖJavaScriptÖеÄeval()º¯Êý

ʵÏÖ²½Ö裺
1.×Ô¶¨ÒåÒ»¸öJavaÀ࣬¸ÃJavaÀàÖж¨ÒåÒ»¸ö·½·¨À´°üº¬ÐèÒª±»ÔËÐеĴúÂë¡£
2.¶¯Ì¬±àÒë¸Õ¸ÕÉú³ÉµÄJavaÔ´Â룬²»ÔÚ´ÅÅÌÉÏÉú³ÉÔ´Â룬¶øÊÇÖ±½Ó±àÒëÄÚ´æÖеÄJavaÔ´Âë¡£
3.¶¯Ì¬¼ÓÔØ¸Õ¸Õ´´½¨±àÒëµÄJava¶þ½øÖÆÂ룬±àÒëºÃµÄJava¶þ½øÖÆÂë²»ÊÇÔÚ´ÅÅÌÉÏ£¬¶øÊÇ·ÅÔÚÄÚ´æÖУ¬²¢¶¨Òå×Ô¼ºµÄÀà¼ÓÔØÆ÷£¬¸ºÔð¼ÓÔØÄÚ´æÖеÄclassÎļþ¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ