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

±¾µØÎı¾Ë÷Òý¼°javaµÄHashMapʵÏÖ

Õâ¸öѧÆÚµÄÐÅÏ¢¼ìË÷¿ÎÒª×öÒ»¸ö´óµÄ×÷Òµ£¬Æäʵ¾ÍÊÇÏ൱ÓÚÒ»¸öËÑË÷ÒýÇ棬µ«ÊÇÊÇ»ùÓÚ±¾µØÎı¾ÎļþµÄ¼ìË÷£¬²»ÐèÒª°ÇÍøÒ³£¬Ò²²»ÄÜʹÓÃLucence»òLemurµÈÇ¿´óµÄµÚÈý·½¿ªÔ´Èí¼þ£¬ÒªÈ«²¿×Ô¼ºÍê³É¡£
Ҫ˵Ë÷Òýµ¹ÊÇÊ®·Ö¼òµ¥£¬¾ÍÊǵ¹ÅŶøÒÑ£¬²¢Ã»ÓÐʲô¸´ÔÓ£¬¶øÇÒµÚÒ»°æµÄ×÷ÒµÒªÇóÖ»ÒªÒÔ×ÖΪË÷Òý¼´¿É£¬¶øÇÒ²»ÐèÒª¶Ô½á¹û½øÐÐÅÅÐòºÍ¸ßÁÁÏÔʾ£¬ÉõÖÁ²»ÐèÒª¼Ç¼¸Ã×ÖÔÚÎĵµÖгöÏֵĴÎÊýºÍλÖá£ËùÒÔÔÚÍê³ÉµÄʱºòÒ²¾ÍÊÇʹÓÃÁËÒ»¸ö½ÏΪ¼òµ¥µÄ´æ´¢Êý¾Ý½á¹¹£¬¼´HashMap<string, HashSet<int>>ÕâÑùÒ»¸ö½á¹¹£¬µÚÒ»¸ö²ÎÊý´æ´¢µÄÊÇ×Ö£¬ºóÃæµÄHashSetÖд洢µÄÊǸÃ×Ö³öÏÖµÄÎĵµºÅ£¬ÓÉÓÚ×ÖºÍÎĵµºÅ¶¼²»ÐèÒªÖظ´¼Ç¼£¬ËùÒÔ²ÉÓÃÁ˹þÏ£½á¹¹¡£
²»¾ÃÓÖ¿ªÊ¼×öÊý¾Ý¿âµÄ×÷Òµ£¬ÄÚÈÝÊÇ»ùÓÚÊý¾Ý¿âµÄÐÅÏ¢¼ìË÷£¬Õâ´ÎµÄÊý¾ÝÁ¿Ïà¶ÔÒª´óºÜ¶à£¬´ó¸ÅÓÐ300¶àMµÄÊý¾Ý£¬¶øÇÒ±ØÐëÓÃC++À´Íê³É£¬¿ªÊ¼ÊÇÓÃSTLµÄmapÀ´×ö£¬µ«ÊÇmapÊÇûÓÐʵÏÖ¹þÏ£µÄ£¬²åÈëʱҪÅжÏÖظ´£¬ËùÒÔËٶȻáÖ¸Êý¼¶±äÂý£¬380ÍòÌõÊý¾Ý´¦Àíµ½50Íòʱ¾ÍÒѾ­Âýµ½²»ÐÐÁË£¬¶øÇÒ³ÔÄÚ´æÊ®·ÖÑÏÖØ£¬ËùÒÔ¾ÍÏ£Íû×Ô¼ºÊµÏÖÒ»¸öHashMap¡£
ËäÈ»ÍøÉÏÒ²ÓÐÏֳɵĴúÂ룬µ«ÊÇ»¹ÊÇÏë×Ô¼ºÐ´Ò»¸ö£¬Ïëµ½javaÖÐÓõ½ÁËJDK1.6µÄHashMap£¬¾ÍÏë×Å˳±ã¿´Ò»ÏÂJDKµÄÔ´Â룬ȻºóÕÕè»­»¢ÒÆÖ²µ½C++ÖУ¬´ó¸Å»¨ÁËÒ»Ìì×óÓÒµÄʱ¼äʵÏÖÁËÒ»¸ö½Ï¼òµ¥µÄ£¬Ã»ÓÐʵÏÖµü´úÆ÷µÄHashMap£¬Ë³±ã¼Ç¼һÏÂÔÚ¿´JDKÔ´ÂëʱµÄһЩÊÕ»ñ£¬±Ï¾¹Ð´µÃ»¹ÊÇÏ൱¾«²ÊµÄ£¬¿ÉÒÔÕâô˵°É¡£
Ê×ÏÈÊÇÉ¢ÁÐÂëµÄ¼ÆË㣬ÕâÊÇ×ö¹þÏ£×îÖØÒªµÄÒ»²¿·Ö£¬Ã»ÓÐÒ»¸öºÃµÄÉ¢Áк¯Êý£¬Ò»Çж¼ÊÇ¿Õ̸£¬ÏÂÃæÊÇJDK1.6ÖйþÏ£µÄ¼ÆË㣬һЩ²ÎÊýÎÒÖ±½Ó³õʼ»¯Ê¹ÓÃÁË£¬Ô´ÂëÖв»ÊÇÕâÑùдµÄ£¬µ«Êǽá¹ûÊÇÒ»ÑùµÄ£¬ÕâÀïÊÇStringÀàhashCodeµÄ¼ÆË㣺
int hashCode(string s) {
int h = 0, off = 0;
int len = s.length();
for (int i = 0; i < len; i++)
h = 31 * h + s[off++];
return h;
}
ÉÏÃæÊÇStringÀàµÄhashCodeµÄ¼ÆË㣬ÔÚHashMapÖУ¬»ùÓÚÕâ¸ö½á¹ûÓÖ½øÐÐÁ˽øÒ»²½¼ÆË㣬Ëã·¨ÈçÏ£º
int hash(int h) {
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
}
ÆäÖвÎÊýh¾ÍÊÇStringµÄhashCode£¬ËäÈ»ÊǼòµ¥µÄËÄ´ÎÒÆλºÍÁù´Î°´Î»Òì»òµÄ¼ÆË㣬µ«ÊÇЧ¹ûÈ´ÊǾªÈ˵ģ¬¾­²âÊÔ£¬ÔÚʹÓÃ0.75×÷Ϊ¸ºÔØÒò×Ó£¬380ÍòÌõÊý¾Ý¹²1Íò¶à¸ö¼üµÄ·Ö²¼Çé¿öÊǼ«ÎªÆ½¾ùµÄ£¬²¢ÇÒÒÆλºÍ°´Î»Âß¼­ÔËËãÊÇÔÚËùÓÐÔËËãÖÐ×î¿ìµÄ£¬¼´Ê¹´¦ÀíµÄ¶¼ÊÇÖÐÎÄЧ¹ûÒ²·Ç³£ºÃ£¬±ÈÆðÍ


Ïà¹ØÎĵµ£º

Àí½âJavaÀà¼ÓÔØÔ­Àí

µÚÒ»²¿·Ö. Ìáʾ
ÎÒÐèÒª¶ÁÕâƪÎÄÕÂÂð£¿
JavaÀà¼ÓÔØÆ÷¶ÔJavaϵͳµÄÔËÐÐÊÇÖÁ¹ØÖØÒªµÄ£¬µ«ÊÇÈ´³£³£±»ÎÒÃǺöÂÔ¡£JavaÀà¼ÓÔØÆ÷¸ºÔØ
ÔÚÔËÐÐʱ²éÕҺͼÓÔØÀà¡£×Ô¶¨ÒåÀà¼ÓÔØÆ÷¿ÉÒÔÍêÈ«¸Ä±äÀàµÄ¼ÓÔØ·½Ê½£¬ÒÔ×Ô¼ºÏ²»¶µÄ·½Ê½À´
¸öÐÔ»¯ÄãµÄJavaÐéÄâ»ú¡£±¾ÎļòÒªµÄ½éÉÜJavaÀà¼ÓÔØÆ÷£¬È»ºóͨ¹ýÒ»¸ö¹¹Ôì×Ô¶¨ÒåÀà¼ÓÔØÆ÷
µÄÀý×ÓÀ´ËµÃ÷£¬Õâ ......

Àí½âJavaÀà¼ÓÔØÔ­Àí

µÚÒ»²¿·Ö. Ìáʾ
ÎÒÐèÒª¶ÁÕâƪÎÄÕÂÂð£¿
JavaÀà¼ÓÔØÆ÷¶ÔJavaϵͳµÄÔËÐÐÊÇÖÁ¹ØÖØÒªµÄ£¬µ«ÊÇÈ´³£³£±»ÎÒÃǺöÂÔ¡£JavaÀà¼ÓÔØÆ÷¸ºÔØ
ÔÚÔËÐÐʱ²éÕҺͼÓÔØÀà¡£×Ô¶¨ÒåÀà¼ÓÔØÆ÷¿ÉÒÔÍêÈ«¸Ä±äÀàµÄ¼ÓÔØ·½Ê½£¬ÒÔ×Ô¼ºÏ²»¶µÄ·½Ê½À´
¸öÐÔ»¯ÄãµÄJavaÐéÄâ»ú¡£±¾ÎļòÒªµÄ½éÉÜJavaÀà¼ÓÔØÆ÷£¬È»ºóͨ¹ýÒ»¸ö¹¹Ôì×Ô¶¨ÒåÀà¼ÓÔØÆ÷
µÄÀý×ÓÀ´ËµÃ÷£¬Õâ ......

java³£¼û´íÎóÒÔ¼°¿ÉÄÜÔ­Òò¼¯½õ

0¡¢ ÐèÒª±êʶ·û
a) ²»ÔÚº¯ÊýÄÚ
1¡¢ ·Ç·¨±í´ïʽ¿ªÊ¼
b) ¿ÉÄÜ:¶ªÊ§À¨ºÅ .
2. no data found
a) ¿ÉÄÜ:setInt(1,100)ÖÐ,ûÓÐ100Õâ¸öÖµ
3. ÕÒ²»µ½·ûºÅ
a) ¿ÉÄÜ:ûµ¼Èë°ü
4. Ö¸¶¨ÁËÎÞЧURL
a) ¿ÉÄÜ:Êý¾Ý¿âÃû»òIP´íÎó,¼´Á¬½Ó³ö´í
5. Àà·¾¶Ã»ÓÐÕÒµ½
a) ¿ÉÄÜ: ClassNotFoundException: oracle.jdbc.driver.Or ......

java Êó±ê»­Ïß

Line.javaÎļþ-------Çý¶¯Àà
import javax.swing.JFrame;
public class Line
{
   public static void main(String[] arg)
   {
       JFrame frame=new JFrame("Draw lines");
       frame.setDefaultCloseOperation(JFrame.EX ......

¶þ²æÊ÷ (Binary Tree) µÄ»ù±¾²Ù×÷ (Java)

package algorithm.binarytree;
import java.util.Arrays;
import java.util.Stack;
import util.ArrayUtil;
import util.OutputUtil;
public class BinTree {
    private BinNode root = null;
    public BinTree()
    {
    }
  &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ