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

javaÖÐhashcode()ºÍequals()µÄÏê½â

תÌû×Ô http://www.javaeye.com/topic/257191
javaÖÐhashcode()ºÍequals()µÄÏê½â
1. Ê×ÏÈequals()ºÍhashcode()ÕâÁ½¸ö·½·¨¶¼ÊÇ´ÓobjectÀàÖм̳йýÀ´µÄ¡£
equals()·½·¨ÔÚobjectÀàÖж¨ÒåÈçÏ£º
  public boolean equals(Object obj) {
return (this == obj);
}
ºÜÃ÷ÏÔÊǶÔÁ½¸ö¶ÔÏóµÄµØÖ·Öµ½øÐеıȽϣ¨¼´±È½ÏÒýÓÃÊÇ·ñÏàͬ£©¡£µ«ÊÇÎÒÃDZØÐèÇå³þ£¬µ±String ¡¢Math¡¢»¹ÓÐInteger¡¢Double¡£¡£¡£¡£µÈÕâЩ·â×°ÀàÔÚʹÓÃequals()·½·¨Ê±£¬ÒѾ­¸²¸ÇÁËobjectÀàµÄequals£¨£©·½·¨¡£±ÈÈçÔÚStringÀàÖÐÈçÏ£º
  public boolean equals(Object anObject) {
if (this == anObject) {
    return true;
}
if (anObject instanceof String) {
    String anotherString = (String)anObject;
    int n = count;
    if (n == anotherString.count) {
char v1[] = value;
char v2[] = anotherString.value;
int i = offset;
int j = anotherString.offset;
while (n-- != 0) {
    if (v1[i++] != v2[j++])
return false;
}
return true;
    }
}
return false;
}
ºÜÃ÷ÏÔ£¬ÕâÊǽøÐеÄÄÚÈݱȽϣ¬¶øÒѾ­²»ÔÙÊǵØÖ·µÄ±È½Ï¡£ÒÀ´ÎÀàÍÆDouble¡¢Integer¡¢Math¡£¡£¡£¡£µÈµÈÕâЩÀ඼ÊÇÖØдÁËequals()·½·¨µÄ£¬´Ó¶ø½øÐеÄÊÇÄÚÈݵıȽϡ£µ±È»ÁË»ù±¾ÀàÐÍÊǽøÐÐÖµµÄ±È½Ï£¬Õâ¸öûÓÐʲôºÃ˵µÄ¡£
ÎÒÃÇ»¹Ó¦¸Ã×¢Ò⣬JavaÓïÑÔ¶Ôequals()µÄÒªÇóÈçÏ£¬ÕâЩҪÇóÊDZØÐë×ñÑ­µÄ£º
• ¶Ô³ÆÐÔ£ºÈç¹ûx.equals(y)·µ»ØÊÇ“true”£¬ÄÇôy.equals(x)Ò²Ó¦¸Ã·µ»ØÊÇ“true”¡£
• ·´ÉäÐÔ£ºx.equals(x)±ØÐë·µ»ØÊÇ“true”¡£
• ÀàÍÆÐÔ£ºÈç¹ûx.equals(y)·µ»ØÊÇ“true”£¬¶øÇÒy.equals(z)·µ»ØÊÇ“true”£¬ÄÇôz.equals(x)Ò²Ó¦¸Ã·µ»ØÊÇ“true”¡£
• »¹ÓÐÒ»ÖÂÐÔ£ºÈç¹ûx.equals(y)·µ»ØÊÇ“true”£¬Ö»ÒªxºÍyÄÚÈÝÒ»Ö±²»±ä£¬²»¹ÜÄãÖظ´x.equals(y)¶àÉٴΣ¬·µ»Ø¶¼ÊÇ“true”¡£
• ÈκÎÇé¿öÏ£¬x.equals(null)£¬ÓÀÔ¶·µ»ØÊÇ“false”£»x.equals(ºÍx²»Í¬ÀàÐ͵ĶÔÏó)ÓÀÔ¶·µ»ØÊÇ“false”¡£
ÒÔÉÏÕâÎåµãÊÇÖØдequals()·½·¨Ê±£¬±ØÐë×ñÊصÄ×¼Ôò£¬Èç¹ûÎ¥·´»á³öÏÖÒâÏë²»µ½µÄ½á¹û£¬Çë´ó¼ÒÒ»¶¨Òª×ñÊØ¡£
2. Æä´ÎÊÇhashcode()


Ïà¹ØÎĵµ£º

Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄÒ»ÖÖ×ö·¨

Java °´×Ö½Ú½ØÈ¡´øÓкº×ÖµÄ×Ö·û´®µÄ½â·¨£¬ÍøÉÏÓв»ÉÙÌÖÂÛ¡£ÕâÀïÎÒÒ²¸ø³öÒ»ÖÖÎÒ×Ô¼ºµÄ´¦Àí£¬»ù±¾Ô­Àí»¹ÊÇͳ¼ÆÒª½ØÈ¡µÄ×Ö½ÚÊýÖÐÊDZíʾºº×ÖµÄ×Ö½ÚÊýÊÇ·ñÊÇżÊý¸ö£¬¼´ÊÇ·ñ¸ÕºÃ°üÀ¨ÁËÍêÕûµÄºº×Ö¡£
/**
 * ±à³Ì£º±àдһ¸ö½ØÈ¡×Ö·û´®µÄº¯Êý£¬ÊäÈëΪһ¸ö×Ö·û´®ºÍ×Ö½ÚÊý£¬Êä³öΪ°´×Ö½Ú½ØÈ¡µÄ×Ö·û´®¡£ µ«ÊÇÒª±£Ö¤ºº×Ö²»±»½Ø°ë¸ ......

java ·´Éä

Ò»¡¢Ê²Ã´ÊÇ·´É䣺
      ·´ÉäµÄ¸ÅÄîÊÇÓÉSmithÔÚ1982ÄêÊ×´ÎÌá³öµÄ£¬Ö÷ÒªÊÇÖ¸³ÌÐò¿ÉÒÔ·ÃÎÊ¡¢¼ì²âºÍÐÞ¸ÄËü±¾Éí״̬»òÐÐΪµÄÒ»ÖÖÄÜÁ¦¡£ÕâÒ»¸ÅÄîµÄÌá³öºÜ¿ìÒý·¢Á˼ÆËã»ú¿ÆѧÁìÓò¹ØÓÚÓ¦Ó÷´ÉäÐÔµÄÑо¿¡£ËüÊ×Ïȱ»³ÌÐòÓïÑÔµÄÉè¼ÆÁìÓòËù²ÉÓÃ,²¢ÔÚLispºÍÃæÏò¶ÔÏó·½ÃæÈ¡µÃÁ˳ɼ¨¡£ÆäÖÐLEAD/LEAD++ ¡¢OpenC+ ......

´«ÖDz¥¿Íjavaѧϰ Spring³õ²½

ÎÒ½ñÌìѧϰÁËÐìÀÏʦ½²µÄSpring֪ʶ£¬ÎÒ×öÁ˼òµ¥µÄ±Ê¼Ç£º
·´Ïò¿ØÖÆ(IOC)
£º
      
bean¹¤³§:×î¼òµ¥µÄÈÝÆ÷£¬ÌṩÁË»ù´¡µÄÒÀÀµ×¢ÈëÖ§³Ö¡£´´½¨¸÷ÖÖÀàÐ͵ÄBean.
Ó¦ÓÃÉÏÏÂÎÄ:½¨Á¢ÔÚbean¹¤³§»ù´¡Ö®ÉÏ£¬Ìṩϵͳ¼Ü¹¹·þÎñ¡£
ClassPathXmlApplicationContext:´ÓÀà·¾¶ÖмÓÔØ¡£
FileSystemXmlAp ......

´«ÖDz¥¿Íjavaѧϰ ½ÌÓý°ì¹«ÏµÍ³1

½ñÌ죬ÎÒÃÇ¿ªÊ¼ÁËÙ¡ÀÏʦµÄ½ÌÓý°ì¹«ÏµÍ³µÄÂọ́ºÎÒ×öÁ˼òµ¥µÄ±Ê¼Ç£º
      
1. ´î½¨ SSH »·¾³
      
1). ¼ÓÈë Struts:
             
¢Ù. ¼ÓÈë jar °ü:
struts-1.3.8\apps\struts-b ......

´«ÖDz¥¿Íjavaѧϰ 3gÊÖ»ú¿ª·¢Android 3

½ñÌìÊÇѧϰ
Android
µÄµÚÈýÌ죬½ñÌìÖ÷ҪѧÁË
Android
ÄÚÖõÄ
SQLite
Êý¾Ý¿â£¬Ñ§Ï°ÁËÔöɾ¸Ä²é¡£
 
      
SharedPreferences
½øÐÐÊý¾Ý´æ´¢
:
      
Android
ƽ̨¸øÎÒÃÇÌṩÁËÒ»¸ö
SharedPreferences
À࣬ËüÊÇÒ»¸öÇáÁ¿¼¶µÄ´æ´¢À࣬ÌرðÊÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ