java equalsÓë== µÄÇø±ð
equals ·½·¨ÊÇ java.lang.Object ÀàµÄ·½·¨¡£
ÓÐÁ½ÖÖÓ÷¨ËµÃ÷£º
£¨1£©¶ÔÓÚ×Ö·û´®±äÁ¿À´Ëµ£¬Ê¹ÓÓ==”ºÍ“equals()”·½·¨±È½Ï×Ö·û´®Ê±£¬Æä±È½Ï·½·¨²»Í¬¡£
“==”±È½ÏÁ½¸ö±äÁ¿±¾ÉíµÄÖµ£¬¼´Á½¸ö¶ÔÏóÔÚÄÚ´æÖеÄÊ×µØÖ·¡£
“equals()”±È½Ï×Ö·û´®ÖÐËù°üº¬µÄÄÚÈÝÊÇ·ñÏàͬ¡£
±ÈÈ磺
String s1,s2,s3 = "abc", s4 ="abc" ;
s1 = new String("abc");
s2 = new String("abc");
ÄÇô£º
s1==s2 ÊÇ false //Á½¸ö±äÁ¿µÄÄÚ´æµØÖ·²»Ò»Ñù£¬Ò²¾ÍÊÇ˵ËüÃÇÖ¸ÏòµÄ¶ÔÏó²» Ò»Ñù£¬
¹Ê²»ÏàµÈ¡£
s1.equals(s2) ÊÇ true //Á½¸ö±äÁ¿µÄËù°üº¬µÄÄÚÈÝÊÇabc£¬¹ÊÏàµÈ¡£
×¢Ò⣨1£©£º
Èç¹û£º StringBuffer s1 = new StringBuffer("a");
StringBuffer s2 = new StringBuffer("a");
½á¹û£º s1.equals(s2) //ÊÇfalse
½âÊÍ£ºStringBufferÀàÖÐûÓÐÖØж¨ÒåequalsÕâ¸ö·½·¨£¬Òò´ËÕâ¸ö·½·¨¾ÍÀ´×ÔObjectÀ࣬
¶øObjectÀàÖеÄequals·½·¨ÊÇÓÃÀ´±È½Ï“µØÖ·”µÄ£¬ËùÒÔµÈÓÚfalse.
×¢Ò⣨2£©£º
¶ÔÓÚs3ºÍs4À´Ëµ£¬ÓÐÒ»µã²»Ò»ÑùÒªÒýÆð×¢Ò⣬ÓÉÓÚs3ºÍs4ÊÇÁ½¸ö×Ö·û
´®³£Á¿ËùÉú³ÉµÄ±äÁ¿£¬ÆäÖÐËù´æ·ÅµÄÄÚ´æµØÖ· ÊÇÏàµÈµÄ£¬
ËùÒÔs3==s4ÊÇtrue£¨¼´Ê¹Ã»ÓÐs3=s4ÕâÑùÒ»¸ö¸³ÖµÓï¾ä£©
£¨2£©¶ÔÓÚ·Ç×Ö·û´®±äÁ¿À´Ëµ£¬"=="ºÍ"equals"·½·¨µÄ×÷ÓÃÊÇÏàͬµÄ¶¼ÊÇÓÃÀ´±È½ÏÆä
¶ÔÏóÔÚ¶ÑÄÚ´æµÄÊ×µØÖ·£¬¼´ÓÃÀ´±È½ÏÁ½¸öÒýÓñäÁ¿ÊÇ·ñÖ¸Ïòͬһ¸ö¶ÔÏó¡£
±ÈÈ磺
class A
{
A obj1 = new A();
A obj2 = new A();
}
ÄÇô£ºobj1==obj2ÊÇfalse
obj1.equals(obj2)ÊÇfalse
µ«ÊÇÈç¼ÓÉÏÕâÑùÒ»¾ä£ºobj1=obj2;
ÄÇô obj1==obj2 ÊÇtrue
obj1.equals(obj2) ÊÇtrue
×ÜÖ®£ºequals·½·¨¶ÔÓÚ×Ö·û´®À´ËµÊDZȽÏÄÚÈݵģ¬¶ø¶ÔÓÚ·Ç×Ö·û´®À´ËµÊDZȽÏ
ÆäÖ¸ÏòµÄ¶ÔÏóÊÇ·ñÏàͬµÄ¡£
== ±È½Ï·ûÒ²ÊDZȽÏÖ¸ÏòµÄ¶ÔÏóÊÇ·ñ
Ïà¹ØÎĵµ£º
1¡¢´´½¨ÁËÒ»¸ö¶ÔÏóºó£º
£¨1£©Ã»ÓÐÔÚÊʵ±µÄµØ·½Êͷŵô
£¨2£©ÔÚÓ¦¸ÃÊͷŵĵط½Ã»ÓÐ×öÊͷŲÙ×÷
ÀýÈ磺ÏÂÃæÒ»¶Î³ÌÐò£º
m_progressDlg = ProgressDialog.show(this, getString(R.string.market),getString(R.string.is_visiting), true);
new Thread() {
public v ......
URI ÊÇ×ÊÔ´±êʶ·û¡£¾ÍÊÇÏ൱ÓÚÒ»¸öÈ˵ļÒͥסַ¡£
URLºÍURIÀàËÆ¡£ÊÇ×ÊÔ´¶¨Î»µÄ¡£ ºÍURI²»Í¬µÄ¾ÍÊÇURLÌṩÁË»ñÈ¡¶«Î÷µÄ·½·¨¡£
java.io.InputStream l_urlStream;
// Ò²¿ÉÒÔ»»³Éuri,È»ºóµ÷ÓÃuri.toURL
  ......
ûÓбØÒªÓÃÒ»¶ÑÈÆ¿ÚµÄÐÎÈÝ´ÊÀ´ÃèÊöʲô½Ð¶à̬£¬Ö»¾Ù³ö¼¸¸ö¹Ø¼üµã¡£
É裺gunΪ¸¸À࣬shootgunºÍpistolΪgunµÄ×ÓÀà¡£
Java:
class gun {
void shoot() {
  ......
JavaµÄÏ̵߳÷¶È²Ù×÷ÔÚÔËÐÐʱÊÇÓëƽ̨Î޹صġ£Ò»¸ö¶àÈÎÎñϵͳÐèÒªÔÚÈÎÎñÖ®¼äʵÏÖQoS(Quality of Service)¹ÜÀíʱ£¬Èç¹ûCPU×ÊÔ´µÄ·ÖÅä»ùÓÚJavaÏ̵߳ÄÓÅÏȼ¶£¬ÄÇôËüÔÚ²»Í¬Æ½Ì¨ÉÏÔËÐÐʱµÄЧ¹ûÊǺÜÄÑÔ¤²âµÄ¡£±¾ÎÄÀûÓÃе÷ʽ¶àÈÎÎñÄ£ÐÍ£¬Ìá³öÒ»¸öÓëƽ̨Î޹ء¢²¢ÇÒÄÜÔÚÈÎÎñ¼ä¶¯Ì¬·ÖÅäCPU×ÊÔ´µÄ·½°¸¡£
ÏÖÔÚ£¬ÓÉÓÚ¼ÆËã»úϵͳÒѾ´ÓÈ ......