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

javaÖÐhashmapºÍhashtableµÄÇø±ð

 
1¡¢  ¼Ì³ÐºÍʵÏÖÇø±ð
HashtableÊÇ»ùÓڳ¾ɵÄDictionaryÀàµÄ£¬HashMapÊÇJava 1.2Òý½øµÄMap½Ó¿ÚµÄÒ»¸öʵÏÖ¡£
2¡¢  Ḭ̈߳²È«²»Í¬
HashTableµÄ·½·¨ÊÇͬ²½µÄ£¬HashMapÊÇδͬ²½£¬ËùÒÔÔÚ¶àÏ̳߳¡ºÏÒªÊÖ¶¯Í¬²½HashMap¡£
3¡¢  ¶ÔnullµÄ´¦Àí²»Í¬
HashTable²»ÔÊÐínullÖµ(keyºÍvalue¶¼²»¿ÉÒÔ),HashMapÔÊÐínullÖµ(keyºÍvalue¶¼¿ÉÒÔ)¡£¼´HashTable ²»ÔÊÐínullÖµÆäʵÔÚ±àÒëÆÚ²»»áÓÐÈκεIJ»Ò»Ñù£¬»áÕÕÑùÖ´ÐУ¬Ö»ÊÇÔÚÔËÐÐÆÚµÄʱºòHashtableÖÐÉèÖõϰ»Ø³öÏÖ¿ÕÖ¸ÕëÒì³£¡£HashMapÔÊÐí nullÖµÊÇÖ¸¿ÉÒÔÓÐÒ»¸ö»ò¶à¸ö¼üËù¶ÔÓ¦µÄֵΪnull¡£µ±get()·½·¨·µ»Ønullֵʱ£¬¼´¿ÉÒÔ±íʾ HashMapÖÐûÓиüü£¬Ò²¿ÉÒÔ±íʾ¸Ã¼üËù¶ÔÓ¦µÄֵΪnull¡£Òò´Ë£¬ÔÚHashMapÖв»ÄÜÓÉget()·½·¨À´ÅжÏHashMapÖÐÊÇ·ñ´æÔÚij¸ö¼ü£¬¶øÓ¦¸ÃÓÃcontainsKey()·½·¨À´Åжϡ£
4¡¢  ·½·¨²»Í¬
HashTableÓÐÒ»¸öcontains(Object value)£¬¹¦ÄܺÍcontainsValue(Object value)¹¦ÄÜÒ»Ñù¡£
5¡¢HashTableʹÓÃEnumeration£¬HashMapʹÓÃIterator¡£
6¡¢HashTableÖÐhashÊý×éĬÈÏ´óСÊÇ11£¬Ôö¼ÓµÄ·½Ê½ÊÇ old*2+1¡£HashMapÖÐhashÊý×éµÄĬÈÏ´óСÊÇ16£¬¶øÇÒÒ»¶¨ÊÇ2µÄÖ¸Êý¡£
7¡¢¹þÏ£ÖµµÄʹÓò»Í¬£¬HashTableÖ±½ÓʹÓöÔÏóµÄhashCode£¬´úÂëÊÇÕâÑùµÄ£º
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
¶øHashMapÖØÐ¼ÆËãhashÖµ£¬¶øÇÒÓÃÓë´úÌæÇóÄ££º
int hash = hash(k);
int i = indexFor(hash, table.length);
static int hash(Object x) {
¡¡¡¡int h = x.hashCode();
¡¡¡¡h += ~(h << 9);
¡¡¡¡h ^= (h >>> 14);
¡¡¡¡h += (h << 4);
¡¡¡¡h ^= (h >>> 10);
¡¡¡¡return h;
}
static int indexFor(int h, int length) {
¡¡¡¡return h & (length-1);
}
 
Çø±ð
 Hashtable
 Hashmap
 
¼Ì³Ð¡¢ÊµÏÖ
 Hashtable<K,V> extends Dictionary<K,V> implements Map<K,V>, Cloneable,Serializable
 HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable,Serializable
 
 
Ïß³Ìͬ²½
 ÒѾ­Í¬²½¹ýµÄ¿ÉÒÔ°²È«Ê¹ÓÃ
 Î´Í¬²½µÄ£¬¿ÉÒÔʹÓÃColletcions½øÐÐͬ²½Map Collections.synchronizedMap(Map m)
 
¶ÔnullµÄ´¦Àí
 
 Hashtable table = new Hashtable();
table.put(null, "Null");
t


Ïà¹ØÎĵµ£º

Effective Java ѧϰ±Ê¼Ç (11)

CloneÕâ¸ö·½·¨ºÜ¼¦Àߣ¬Ô­ÒòÊÇÒòΪËüÊÇÊܱ£»¤µÄ(protected)£¬Æä¶þCloneÕâ¸ö·½·¨ÊÇ¿ÉÑ¡µÄ£¬¼´ÓпÉÄÜÀàûÓÐÌṩÕâ¸ö·½·¨¡£
cloneûÓе÷Óù¹Ô캯Êý£¬¶øÇÒÈç¹û¸¸ÀàûÓÐʵÏÖcloneµÄ»°£¬×ÓÀàÓÀÔ¶Ò²²»¿ÉÄÜÕýȷʵÏÖclone.
×ÜÖ®£¬cloneÊǸöºÜÍ·Í´µÄº¯Êý£¬Èç¹ûÒªÕýȷʵÏÖ£¬±ØÐ뿼Âǵ½É±´µÄÇé¿ö£¬·ñÔò±»¿Ë¡³öÀ´µÄ¶ÔÏó¾Í²»ÊǶÀÁ¢µÄ ......

Java Web µÚ¶þÌì Servlet»ù´¡

Ò»¡¢
ʲôÊÇ
Servlet
Servlet
ÔÚ
web
ÈÝÆ÷ÖÐÓÃÀ´´´½¨¶¯Ì¬ÍøÒ³Óõģ¬ÒòΪËûûÓÐ
main
·½·¨£¬ËùÒÔ
Servlet
²»ÊÇÒ»¸öÍêÕûµÄ
Java
Ó¦ÓóÌÐò¡£
¶þ¡¢
Servlet
µÄ±àд
×î»ù±¾µÄ
Servlet
Òª°üÀ¨Èý²¿·Ö£¬·Ö±ðΪ
Servlet-name
¡¢
Servlet-class
¡¢
url-pattern
¡£
Èý¡¢
Servlet API
Generi
Servlet
ÊµÏ ......

Java Web µÚÈýÌì Servlet´¦ÀíÏìÓ¦

Ò»¡¢
HTTP
ÏìÓ¦µÄ¸ñʽ
ÏìÓ¦ÐУº
HTTP
°æ±¾¡¢ÏìÓ¦Âë¡¢ÏìÓ¦ÃèÊö
ÏìӦͷ
¿ÕÐÐ
ÏûÏ¢Ìå
HTTP
ĬÈϵÄÎı¾±àÂëΪ£º
ISO-8895-1
¶þ¡¢
ÏìÓ¦ÂëµÄÉèÖÃ
1.      

ʲôÊÇÏìÓ¦Âë
ÏìÓ¦ÂëλÓÚ
HTTP
ÏìÓ¦µÄÏìÓ¦ÐÐÖУ¬ËûÓÃÀ´ÃèÊöµ±Ç°
Servlet
µÄÒ»Ð©ÖØÒªÐÅÏ¢¡£³£¼ûµÄÏìÓ¦ÂëÓÐ
200.302 ......

Lucene£º»ùÓÚJavaµÄÈ«ÎļìË÷ÒýÇæ¼ò½é


LuceneÊÇÒ»¸ö»ùÓÚJavaµÄÈ«ÎÄË÷Òý¹¤¾ß°ü¡£
»ùÓÚJavaµÄÈ«ÎÄË÷ÒýÒýÇæLucene¼ò½é£º¹ØÓÚ×÷ÕߺÍLuceneµÄÀúÊ·
È«ÎļìË÷µÄʵÏÖ£ºLueneÈ«ÎÄË÷ÒýºÍÊý¾Ý¿âË÷ÒýµÄ±È½Ï
ÖÐÎÄÇзִʻúÖÆ¼ò½é£º»ùÓÚ´Ê¿âºÍ×Ô¶¯ÇзִÊËã·¨µÄ±È½Ï
¾ßÌåµÄ°²×°ºÍʹÓüò½é£ºÏµÍ³½á¹¹½éÉܺÍÑÝʾ
Hacking Lucene£º¼ò»¯µÄ²éѯ·ÖÎöÆ÷£¬É¾³ýµÄʵÏÖ£¬¶¨ÖƵÄÅ ......

¼ÙÆÚûÊÂ,дÁ˸ö90ÐеĶíÂÞ˹·½¿é,JavaʵÏÖ

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Terris extends JFrame implements Runnable, KeyListener {
private short isPlaying=0,xOffSet = 2, yOffSet = 0, blockType = (short) Math.round(Math.random() * 6), blockRotation = 0, blockColor = (short) Math.round(Math. ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ