JavaÖÐequalºÍ==µÄ±È½Ï[zz]
×î½ü¿´µ½Ò»¸öÍøÓѹØÓÚ==ºÍequals ×öµÄ×ܽᣬ·ÖÏíÒ»ÏÂ
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ȽÏÖ¸ÏòµÄ¶ÔÏóÊÇ·ñÏàͬµÄÒ²¾ÍÊǶÔÏóÔÚ¶ÔÄÚ´æÖеĵÄÊ×µØÖ·¡£
StringÀàÖÐÖØж¨ÒåÁËequalsÕâ¸ö·½·¨£¬¶øÇұȽϵÄÊÇÖµ£¬¶ø²»ÊǵØÖ·¡£ËùÒÔÊÇtrue¡£
¹ØÓÚequalsÓë==µÄÇø±ð´ÓÒÔϼ¸¸ö·½ÃæÀ´Ëµ£º
£¨1£©Èç¹ûÊÇ»ù±¾ÀàÐͱȽϣ¬ÄÇôֻÄÜÓÃ==À´±È½Ï£¬²»ÄÜÓÃequals
±ÈÈ磺
public class TestEquals {
public static void main(String[] args)
{
int a = 3;
int b = 4;
int c = 3;
System.out.println(a == b);//½á¹ûÊÇfalse
System.out.println(a == c);//½á¹ûÊÇtrue
System.out.pr
Ïà¹ØÎĵµ£º
ÉÏ´Î談過ÁËʹÓÃiText產ÉúPDF檔£¬這´Î換³É來談談ʹÓÃJExcel來產ÉúEXCEL檔µÄ·½·¨¡£
Ê×ÏÈ£¬Ïȵ½ËûµÄSourceForgeÖ÷頁ÃædownloadÏà關µÄAPI檔°¸¡£
http://sourceforge.net/projects/jexcelapi/
»ò
http://www.andykhan ......
ѧϰJavaÖµ´«µÝ·½·¨-Î人±±´óÇàÄñ
¡¡¡¡Öµ´«µÝÊÇÔÚÒ»¸öº¯ÊýÖУ¬µ÷ÓÃÁíÍâÒ»¸öº¯Êý£¬ÆäÖк¬ÓвÎÊý´«µÝµÄÇé¿ö¡£ÍùÍùÖµ´«µÝ¾ÍÊÇ°ÑÊý¾Ý´«µÝµ½ÁíÍâÒ»¸öº¯ÊýÖнøÐнøÒ»²½´¦Àí£¬ÒÔ¸üÇå³þµØÏÔʾº¯ÊýµÄ±í´ïÒâ˼¡£ÔÚº¯Êýµ÷ÓõÄʱºò»áÓÐÊý¾Ý´«µÝ£¬Í¬ÑùÒª¿¼ÂÇÐβκÍʵ²ÎµÄÎÊÌ⣬ÈçÏÂÃæµÄÒ»¸ö³ÌÐò£º
¡¡¡¡on error resume next ShockMode ......
Reflection ÊÇ Java ³ÌÐò¿ª·¢ÓïÑÔµÄÌØÕ÷Ö®Ò»£¬ËüÔÊÐíÔËÐÐÖÐµÄ Java ³ÌÐò¶Ô×ÔÉí½øÐмì²é£¬»òÕß˵“×ÔÉ󔣬²¢ÄÜÖ±½Ó²Ù×÷³ÌÐòµÄÄÚ²¿ÊôÐÔ¡£ÀýÈ磬ʹÓÃËüÄÜ»ñµÃ Java ÀàÖи÷³ÉÔ±µÄÃû³Æ²¢ÏÔʾ³öÀ´¡£
Java µÄÕâÒ»ÄÜÁ¦ÔÚʵ¼ÊÓ¦ÓÃÖÐÒ²ÐíÓõò»ÊǺܶ࣬µ«ÊÇÔÚÆäËüµÄ³ÌÐòÉè¼ÆÓïÑÔÖиù±¾¾Í²»´æÔÚÕâÒ»ÌØÐÔ¡£ÀýÈ磬Pascal¡¢C ......
ÎÊÌâÒ»£ºÈç±£¼ÓÔØJDBCÇý¶¯³ÌÐò£º
Õý³£ÎÒÃǼÓÔØÇý¶¯³ÌÐòÓÐÈý¸ö;¾¶£º
1.Class.forName(String)ÕâÏëµ±ÓÚclassLoaderÒ»¸öStringÖ¸¶¨µÄÀ࣬ÔÚ×°ÔØʱ°Ñ¸ÃÇý¶¯³ÌÐòµÄ¾²Ì¬ÄÚÈݶ¼³õʼ»¯£¬ÆäʵÕâʱÇý¶¯³ÌÐòÀàµ÷ÓÃÁËDriverManager.registerDriver(driver)·½·¨¡£
2.ʹÓÃϵͳÊôÐÔ£ºSystem.getPro ......
ÕâÈý¸öÓïÑÔ·Ö±ðÊÇÈý¸ö¹«Ë¾¿ª·¢µÄ£¬SUNµÄJava£¬NetscapeµÄJavaScript£¬MicrosoftµÄJScript
JavaScriptÊÇÓÉNetscape¹«Ë¾¿ª·¢²¢ËæNavigatorµ¼º½ÕßÒ»Æð·¢²¼µÄ¡¢½éÓÚJavaÓëHTMLÖ®¼ä¡¢»ùÓÚ¶ÔÏóʼþÇý¶¯µÄ±à³ÌÓïÑÔ£¬²»ÐèÒªJava±àÒëÆ÷£¬¶øÊÇÖ±½ÓÔËÐÐÔÚWebä¯ÀÀÆ÷ÖУ¬ËüµÄÇ°ÉíÊÇLive Script¡£
JScriptÊÇÒ»ÖÖÀàËÆJavaScriptµÄÓïÑÔ¡ ......