java ×Ö·û´®±È½Ï
ÊìϤC++µÄÈ˶ÔÓÚÁ½¸ö×Ö·û´®±È½ÏµÄ´úÂëÒ»¶¨ºÜÁ˽⣺
(string1==string2)
µ«ÔÚjavaÖУ¬Õâ¸ö´úÂ뼴ʹÔÚÁ½¸ö×Ö·û´®ÍêÈ«ÏàͬµÄÇé¿öÏÂÒ²»á·µ»Øfalse
JavaÖбØÐëʹÓÃstring1.equals(string2)À´½øÐÐÅжÏ
²¹³ä
Èç¹û£º
string s1=new String("Hello");
string s2=new String("Hello");
Ôò(s1==s2)=false
Èç¹û£º
string s1="Hello";
string s2="Hello";
Ôò(s1==s2)=true;
ÒòΪËûÃÇÖ¸ÏòµÄͬһ¸ö¶ÔÏó¡£
Èç¹û°ÑÆäËû±äÁ¿µÄÖµ¸³¸øs1ºÍs2£¬¼´Ê¹ÄÚÈÝÏàͬ£¬ÓÉÓÚ²»ÊÇÖ¸Ïòͬһ¸ö¶ÔÏó£¬Ò²»á·µ»Øfalse¡£ËùÒÔ½¨ÒéʹÓÃequals()£¬ÒòΪequals±È½ÏµÄ²ÅÊÇÕæÕýµÄÄÚÈÝ
Ïà¹ØÎĵµ£º
1¡¢ ´®²Ù×÷£ºÊ¹ÓÃ×Ö·û´®´æÖüÒ»¸öÓ¢Îľä×Ó“Java is an object oriented programming
language”¡£ÏÔʾ¸Ã¾ä×Ó£¬²¢Ëã³öÿ¸öµ¥´ÊµÄ×ÖĸÊýºÍƽ¾ù×ÖĸÊý£¬²¢°´µ¥´ÊÉýÐòÅÅÁÐÊä³ö£¨²»ÓÃÊý×飬ֻÓô®²Ù×÷£©
public class homework21 {
public static void main(String[] args) {
&nb ......
Ò»°ãµÄÊÊÓÃÓÚS40µÄJAVAÈí¼þ¶¼¿ÉÒÔ×°ÔÚŵ»ùÑÇ3110cÉÏ,°üÀ¨ÓÎÏ·,µç×ÓÊé,Ó¦ÓÃÈí¼þ ʲôÊÇJAVAÈí¼þÄØ£¿
JavaÊÇÓÉSun΢ϵͳ¹«Ë¾Ëù·¢Õ¹³öÀ´µÄ³ÌÐòÓïÑÔ£¬Ëü±¾ÉíÊÇÒ»ÖÖ¶ÔÏóµ¼Ïò£¨Object-Oriented£©µÄ³ÌÐòÓïÑÔ¡£JAVAĿǰÔÚÊÖ»úÉÏÓ¦ÓÃ×î¶àµÄ¾ÍÊÇJAVAÓÎÏ·¡£
JavaÒ²ºÅ³ÆÊÇÄÜ¿çÆ½Ì¨Ê¹ÓõÄÓïÑÔ£¬ÕâÖ÷ÒªÊÇÒòΪJava±¾Éí±»±àÒëÖ®ºó£¬²¢² ......
SetºÍÊýѧÖеļ¯ºÏÊÇͬһ¸ö¸ÅÄ¾ÍÊÇûÓÐÖØ¸´ÔªËصļ¯ºÏ¡£
ÕâÆªÎÄÕÂÖ÷ÒªÂÛÊöÁËSetÊÇÈçºÎʵÏÖ"ûÓÐÖØ¸´ÔªËØ"£¨no duplicate elements£©µÄ£¬ÒÔ¼°²ûÊöÁËʲôÊÇ“ÖØ¸´”£¨duplicate£©£¬ÊÇÏàͬµÄµØÖ·¿Õ¼ä£¿ÊÇequalsµÄ·µ»ØÖµÎªtrue£¿ÊÇcompareToµÄ·µ»ØÖµÎª0 £¿»¹ÊÇÓÐÏàͬµÄhashCode£¿±¾ÎÄ»¹¸ø³öÁËÔÚʲôÇé¿öÏÂʹÓÃʲà ......
finalÀࣺΪ·ÀÖ¹ËûÈË´ÓÄãµÄÀàÉÏÅÉÉúÐÂÀ࣬´ËÀàÊDz»¿ÉÀ©Õ¹µÄ¡£
¡¡¡¡¶¯Ì¬µ÷ÓñȾ²Ì¬µ÷Óû¨·ÑµÄʱ¼äÒª³¤¡£
¡¡¡¡³éÏóÀࣺ¹æ¶¨Ò»¸ö»ò¶à¸ö³éÏó·½·¨µÄÀà±¾Éí±ØÐ붨ÒåΪabstract¡£
¡¡¡¡Àý£º public abstract string getDescripition
¡¡¡¡JavaÖеÄÿһ¸öÀà¶¼ÊÇ´ÓObjectÀàÀ©Õ¹¶øÀ´µÄ¡£
¡¡¡¡objectÀàÖеÄequalºÍtoString·½· ......