ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡
°Ë¶þµç×ÓÊé ·µ»Ø±¾ÊéĿ¼ ¼ÓÈëÊéÇ© ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ¡ºÊղص½ÎÒµÄä¯ÀÀÆ÷¡»

JavaÓïÑÔÈëÃÅ-µÚ5²¿·Ö

¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿! Èç¹û±¾ÊéûÓÐÔĶÁÍ꣬ÏëÏ´μÌÐø½Ó×ÅÔĶÁ£¬¿ÉʹÓÃÉÏ·½ "Êղص½ÎÒµÄä¯ÀÀÆ÷" ¹¦ÄÜ ºÍ "¼ÓÈëÊéÇ©" ¹¦ÄÜ£¡


Interger¡£toString£¨decimalValue£»8£©£»£ýif£¨whick¡£equals£¨¡±Hex¡±£©£©
£ûdecimalValue=Integer¡£parseInt£¨dDisplay¡£getText£¨£©£©£»baseXValue=
Interger¡£toString£¨decimalValue£»16£©£»£ýif£¨whick¡£equals£¨¡±36¡±£©£©
£ûdecimalValue=Integer¡£parseInt£¨dDisplay¡£getText£¨£©£©£»baseXValue=
Interger¡£toString£¨decimalValue£»36£©£»£ýupdateXDisplay£¨£©£»returntrue£»£ý
returnfalse£»£ý
publicstaticvoidmain£¨Stringargs£§£§£©£ûd2xm=newd2x£¨£©£»m¡£start£¨£©£»£ý£ý
±¾ÕÂС½á£º
¡¡¡¡1¡£javaÓÐÁ½ÖÖÀàÐ͵ÄÓ¦ÓóÌÐò£¬Ò»ÖÖÊÇÖ±½ÓÔËÐÐÔÚjavaÐéÄâ»úÉÏ£¬ÓÃjavaÃüÁîÖ´ÐУ»ÁíÒ»ÖÖÔËÐÐÔÚä¯ÀÀÆ÷ÀÓÉä¯ÀÀÆ÷µ÷ÓÃÖ´ÐУ¬Ò»°ã³ÆËüΪAppletС³ÌÐò¡£±¾ÊéÖ÷ÒªÌÖÂÛµÚÒ»ÖÖÓ¦ÓóÌÐò¡£2¡£javaÓ¦ÓóÌÐòÊÇÓÉÀà×é³ÉµÄ£¬¶øÇÒÓÃjavaÃüÁîÐÐÖ´ÐеÄÀà±ØÐëÓÐmainÈë¿Úº¯Êý¡£3¡£ÓëCÓïÑÔÏàËÆ£¬java³ÌÐòÒ²¿ÉÓÉÃüÁîÐд«µÝ¸ømainº¯Êý²ÎÊý¡£4¡£»ù±¾´°¿Újava³ÌÐòµÄ»ù±¾ÀàÊÇFrame¡£ÀûÓÃËü¿ÉÒԺܷ½±ãµØ½¨Á¢Í¼ÐÎÓû§½çÃæ³ÌÐò¡£
µÚÎåÕÂJavaµÄÀà
ÀàÊÇJavaÓïÑÔÃæÏò¶ÔÏó±à³ÌµÄ»ù±¾ÔªËØ£¬Ëü¶¨ÒåÁËÒ»¸ö¶ÔÏóµÄ½á¹¹ºÍÐÐΪ¡£ÔÚJava³ÌÐòÀÄãÒª±í´ïµÄ¸ÅÄî·â×°ÔÚij¸öÀàÀï¡£Ò»¸öÀඨÒåÁËÒ»¸ö¶ÔÏóµÄ½á¹¹ºÍËüµÄ¹¦Äܽӿڣ¬¹¦ÄܽӿڳÆΪ³ÉÔ±º¯Êý¡£µ±Java³ÌÐòÔËÐÐʱ£¬ÏµÍ³ÓÃÀàµÄ¶¨Òå´´½¨ÀàµÄʵÀý£¬ÀàµÄʵÀýÊÇÕæÕýµÄ¶ÔÏó¡£ÀඨÒåµÄÒ»°ãÐÎʽÈçÏ£º
classclassnameextendssuperclassname£ûtypeinstance¡­variable1£»typeinstance¡­variable2£»¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£typeinstance¡­variableN£»typemethodname1£¨parameter¡­list£©£ûmethod¡­body£»£ýtypemethodname2£¨parameter¡­list£©£ûmethod¡­body£»£ý¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£typemethodnameN£¨parameter¡­list£©£ûmethod¡­body£»£ý£ý
ÕâÀclassnameºÍsuperclassnameÊǺϷ¨µÄ±êʶ·û¡£¹Ø¼ü´ÊextendsÓÃÀ´±íÃ÷classnameÊÇsuperclassnameÅÉÉúµÄ×ÓÀà¡£ÓÐÒ»¸öÀà½Ð×öObject£¬ËüÊÇËùÓÐJavaÀàµÄ¸ù¡£Èç¹ûÄãÏ붨ÒåObjectµÄÖ±½Ó×ÓÀ࣬Äã¿ÉÒÔÊ¡ÂÔextends×Ӿ䣬±àÒëÆ÷»á×Ô¶¯°üº¬Ëü¡£ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÀàµÄ¶¨Òå¡£classUniversity£û£ý
5¡£1¶ÔÏóʵÀý
ÀàÃû¿ÉÒÔ×÷Ϊ±äÁ¿µÄÀàÐÍÀ´Ê¹Óã¬Èç¹ûÒ»¸ö±äÁ¿µÄÀàÐÍÊÇij¸öÀ࣬ÄÇôËü½«Ö¸ÏòÕâ¸öÀàµÄʵÀý£¬³ÆΪ¶ÔÏóʵÀý¡£ËùÓжÔÏóʵÀýºÍËüÃǵÄÀàÐÍ£¨Ä³¸öÀࣿcopy£»µÄ×ÓÀàµÄʵÀý¶¼ÊÇÏàÈݵġ£¾ÍÏó¿ÉÒÔ°ÑbyteÐ͵ÄÖµ¸³¸øintÐ͵ıäÁ¿Ò»Ñù£¬Äã¿ÉÒÔ°ÑObjectµÄ×ÓÀàµÄÈκÎʵÀý¸³¸øÒ»¸öObjectÐ͵ıäÁ¿¡£Ò»¸öʵÀýÊÇÀàÄ£°åµÄµ¥¶ÀµÄ¿½±´£¬´øÓÐ×Ô¼ºµÄ³ÆΪʵÀý±äÁ¿µÄÊý¾Ý¼¯¡£Ã¿¸öʵÀýÒ²¿ÉÒÔ×÷Ϊһ¸ö¶ÔÏó¡£µ±Ä㶨ÒåÒ»¸ö±äÁ¿µÄÀàÐÍÊÇij¸öÀàʱ£¬ËüµÄȱʡֵÊÇnull£¬nullÊÇObjectµÄÒ»¸öʵÀý¡£¶ÔÏónullûÓÐÖµ£¬ËüºÍÕûÊý0²»Í¬¡£ÏÂÃæÕâ¸öÀý×ÓÖУ¬ÉùÃ÷±äÁ¿uµÄÀàÐÍÊÇÀàUniversity¡£Universityu£»ÕâÀ±äÁ¿uµÄÖµÊÇnull¡£
5¡£2ʵÀý±äÁ¿
Javaͨ¹ýÔÚÀඨÒåµÄ´óÀ¨ºÅÀïÉùÃ÷±äÁ¿À´°ÑÊý¾Ý·â×°ÔÚÒ»¸öÀàÀï¡£ÕâÀïµÄ±äÁ¿³ÆΪʵÀý±äÁ¿¡£ÏÂÃæµÄÀý×Ó¶¨ÒåÁËÒ»¸ö½Ð×öUniversityµÄÀ࣬ËüÓÐÁ½¸öʵÀý±äÁ¿£ºnameºÍcity¡£classUniversity£ûStringname£»city£»£ý
5¡£3new²Ù×÷·û
²Ù×÷·ûnewÓÃÀ´Éú³ÉÒ»¸öÀàµÄʵÀý£¬ÏÂÃæÕâ¸öÀý×ÓÉú³ÉÁËÀàUniversityµÄÒ»¸öʵÀý£¬´æ·ÅÔÚ±äÁ¿uÖС£
Universityu=newUniversity£¨£©£»ÔÚ´ËÀýÖУ¬±äÁ¿uÖ¸ÏòÕâ¸ö¶ÔÏ󣬵«²¢²»ÕæÕý°üº¬Õâ¸ö¶ÔÏó¡£Äã¿ÉÒÔÓöà¸ö±äÁ¿Ö¸Ïòͬһ¸ö¶ÔÏó¡£ÏÂÃæµÄÀý×ÓÖУ¬´´½¨ÁËÒ»¸öUniversityµÄ¶ÔÏ󣬵«´´½¨ÁËÁ½¸öÖ¸ÏòËüµÄ±äÁ¿¡£
Universityu=newUniversity£¨£©£»Universityu2=u£»
¶Ôu2ËùÖ¸ÏòµÄ¶ÔÏóµÄÈκθĶ¯¶¼»á¶ÔuËùÖ¸ÏòµÄ¶ÔÏóÆð×÷Óã¬ÒòΪËüÃÇÊÇͬһ¸ö¶ÔÏ󡣶ÔuºÍu2µÄ¸³ÖµÖ»ÊÇ°ÑËüÃÇÖ¸ÏòÕâ¸ö¶ÔÏ󣬼ÈûÓзÖÅäÄڴ棬ҲûÓи´ÖÆÕâ¸ö¶ÔÏóµÄÈκβ¿·Ö¡£¶ÔuµÄÔÙ¸³ÖµÖ»ÊǼòµ¥µØÈ¥µôÁËuºÍÔ­À´¶ÔÏóµÄÁªÏµ£¬²¢²»Ó°Ïì¶ÔÏó±¾Éí£¬ÏÂÃæµÄÀý×Ó˵Ã÷ÁËÕâÖÖÇé¿ö¡£
Universityu=newUniversity£¨£©£»Universityu2=u£»u=null£»
¾¡¹Üu±»¸³ÖµÎªnull£¬u2ÈÔÖ¸ÏòÔ­À´ÓɲÙ×÷·ûnew´´½¨µÄ¶ÔÏó¡£ÔÚÇ°ÃæµÄÀý×ÓÀÎÒÃÇÉú³ÉÁËÒ»¸ö¶ÔÏó²¢ÇÒÖ¸ÏòÁËËüÁ½´Î¡£Õâ¾ÍÔÊÐíÁ½¸ö±äÁ¿¸Ä±äͬһ¸ö¶ÔÏó¡£´´½¨Ò»¸öеĶÔÏóʱ£¬¿ÉÖ±½Ó¶ÔËüµÄʵÀý±äÁ¿¸³Öµ¡£Ã¿¸ö¶ÔÏó¶¼ÓÐËüËùÊôÀàµÄʵÀý±äÁ¿µÄ¿½±´£¬Ã¿¸ö¶ÔÏóµÄʵÀý±äÁ¿¶¼ÊǺÍÆäËû¶ÔÏóµÄʵÀý±äÁ¿·ÖÀëµÄ£¬ËùÒԸıäÒ»¸ö¶ÔÏóµÄʵÀý±äÁ¿²»»áÓ°ÏìÆäËû¶ÔÏóµÄʵÀý±äÁ¿¡£ÏÂÃæµÄÀý×Ó´´½¨ÁËÁ½¸öUniversityµÄ¶ÔÏ󣬲¢¶ÔËüÃÇ·Ö±ð¸³Öµ£ºclassTwoUniversity£ûpublicstaticvoidmain£¨Stringargs£§£§£©£ûUniversityu1=newUniversity£¨£©£»Universityu2=newUniversity£¨£©£»u1¡£name=¡±±±£¿copy£»´óѧ¡±£»u1¡£city=¡±±±£¿copy£»¡±£»u2¡£name=¡±Ç廪´óѧ¡±£»u2¡£city=¡±±±£¿copy£»¡±£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u1¡£name£«¡±³ÇÊУº¡±£«u1¡£city£©£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u2¡£name£«¡±³ÇÊУº¡±£«u2¡£city£©£»£ý£ýÕâ¸öÀý×Ó´´½¨ÁËÁ½¸öUniversityµÄ¶ÔÏ󣬲¢ÇÒ¶ÔËüÃǵÄname¡¢city·Ö±ð¸³Á˲»Í¬µÄÖµ£¬Õâ˵Ã÷ÕâÁ½¸ö¶ÔÏóÊÇÕæÕý·ÖÀëµÄ¡£ÏÂÃæÊǸóÌÐòÔËÐкóµÄÊä³ö½á¹û¡£C£º¡·javaTwoUniversity´óѧ£º±±£¿copy£»´óѧ³ÇÊУº±±£¿copy£»´óѧ£ºÇ廪´óѧ³ÇÊУº±±£¿copy£»
5¡£4µã£¨¡££¿copy£»²Ù×÷·ûµã£¨¡££¿copy£»²Ù×÷·ûÓÃÀ´½ÓÊÕÒ»¸ö¶ÔÏóµÄʵÀý±äÁ¿ºÍ³ÉÔ±º¯Êý¡£ÏÂÃæÊÇÓõã²Ù×÷·ûÀ´½ÓÊÕʵÀý±äÁ¿µÄÒ»°ãÐÎʽ¡£objectreference¡£variablename
ÕâÀïobjectreferenceÊÇÒ»¸ö¶ÔÏóʵÀý£¬variablenameÊÇÕâ¸ö¶ÔÏóÀïÄãÏë½ÓÊÕµÄʵÀý±äÁ¿¡£ÏÂÃæµÄ³ÌÐò¶Î˵Ã÷ÁËÔõÑùÓõã²Ù×÷·ûÀ´¸øʵÀý±äÁ¿¸³Öµ¡£
u¡£name=¡±±±£¿copy£»´óѧ¡±£»u¡£city=¡±±±£¿copy£»¡±£»ÏÂÃæ˵Ã÷ÔõÑùÓõã²Ù×÷·ûÀ´µÃµ½ÊµÀý±äÁ¿µÄÖµ¡£System¡£out¡£println£¨¡±´óѧ£º¡±£«u¡£name£«¡±³ÇÊУº¡±£«u¡£city£©£»Í¨¹ýÏòÀàUniversityÀï¼ÓÈëÒ»¸ö³ÉÔ±º¯Êýmain£¬ÎÒÃÇ´´½¨ÁËÒ»¸öÍêÕûµÄÀý×Ó£¬ËüʹÓÃÁËnew²Ù×÷·ûÀ´´´½¨Ò»¸öUniversity£¬Óõã²Ù×÷·ûÀ´¸³Öµ£¬È»ºó´òÓ¡½á¹û¡£classUniversity£ûStringname£»city£»publicstaticvoidmain£¨Stringargs£§£§£©£ûUniversityu=newUniversity£¨£©£»u¡£name=¡±±±£¿copy£»´óѧ¡±£»u¡£city=¡±±±£¿copy£»¡±£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u¡£name£«¡±³ÇÊУº¡±£«u¡£city£©£»£ý£ý
ÔËÐÐÕâ¸ö³ÌÐòºó£¬¾Í»áµÃµ½ÏÂÃæµÄ½á¹û¡£C£º¡·javaUniversity´óѧ£º±±£¿copy£»´óѧ³ÇÊУº±±£¿copy£»
5¡£5³ÉÔ±º¯Êý¶¨Òå
³ÉÔ±º¯Êý£¬ÊÇÀàµÄ¹¦Äܽӿڣ¬ÊÇÀඨÒåÀïµÄÒ»¸ö×Ó³ÌÐò£¬ÔÚÀàµÄ¶¨ÒåÀïºÍʵÀý±äÁ¿´¦ÓÚͬһ¼¶±ð¡£Äã±ØÐëͨ¹ýÒ»¸öÀàµÄʵÀýÀ´µ÷ÓóÉÔ±º¯Êý¡£³ÉÔ±º¯Êý¿ÉÒÔ²»Óõã²Ù×÷·û¶øÖ±½ÓʹÓÃʵÀý±äÁ¿¡£³ÉÔ±º¯Êý´øÓÐÊäÈë²ÎÊý£¬¾ßÓÐ
ijÖÖÀàÐ͵ķµ»ØÖµ¡£³ÉÔ±º¯Êý¶¨ÒåµÄÒ»°ãÐÎʽÈçÏ£ºtypemethodname£¨formal¡­parameter¡­list£©£ûmethod¡­body£»£ýÕâÀïtypeÖ¸µÄÊdzÉÔ±º¯ÊýµÄ·µ»ØÖµµÄÀàÐÍ£¬Èç¹ûûÓзµ»ØÖµ£¬¾ÍÓÃÎÞÖµ£¨void£¿copy£»ÀàÐÍ¡£methodname¿ÉÒÔÊÇÈκκϷ¨µÄ±êʶ·û£¬µ«²»ÄÜÓ뵱ǰµÄÀàÃûÏàͬ¡£formal¡­parameter¡­listÊÇÓöººÅ·Ö¸ôµÄÀàÐÍ¡¢±êʶ·û¶ÔµÄÐòÁС£Èç¹ûûÓвÎÊý£¬À¨ºÅÀï¾ÍÊǿյġ£»¹ÊÇÓÃÎÒÃǵÄUniversityµÄÀý×Ó£¬ÏÂÃæµÄ³ÉÔ±º¯ÊýÓÃÀ´³õʼ»¯Á½¸öʵÀý±äÁ¿¡£³ÉÔ±º¯ÊýÊÇÔÚÀàµÄ´óÀ¨ºÅ£¿reg£»ÄÚ¶¨ÒåµÄ£¬ºÍʵÀý±äÁ¿Ëù´¦µÄ·¶Î§Ïàͬ¡£classUniversity£ûStringname£»city£»voidinit£¨Stringa£»Stringb£©£ûname=a£»city=b£»£ý£ý
×¢Ò⣬ÎÒÃÇÕâÀïÖ±½Ó¸ønameºÍcity¸³Öµ£¬¶øûÓÐÏóÒÔÇ°ÄÇÑùÓÃu1¡£name¡£ÕâÊÇÒòΪÿ¸ö³ÉÔ±º¯Êý¶¼ÔÚÀàµÄ¸ö±ðʵÀýÄÚÖ´ÐС£ÎÒÃÇ´´½¨µÄÀàµÄʵÀý¾ßÓÐËü×Ô¼ºµÄʵÀý±äÁ¿£¬ËùÒÔ³ÉÔ±º¯Êý¿ÉÖ±½ÓʹÓÃËüÃÇ¡£
5¡£6³ÉÔ±º¯Êýµ÷ÓÃ
¿ÉÒÔÓõ㣨¡££¿copy£»²Ù×÷·ûÀ´µ÷ÓÃÒ»¸öÀàµÄʵÀýµÄ³ÉÔ±º¯Êý¡£³ÉÔ±º¯Êýµ÷ÓõÄÒ»°ãÐÎʽÈçÏ£ºobjectreference¡£methodname£¨parameter¡­list£©£»ÕâÀobjectreferenceÊÇÖ¸Ïòij¸ö¶ÔÏóµÄ±äÁ¿£¬methodnameÊÇobjectreferenceËùÊôÀàµÄÒ»¸ö³ÉÔ±º¯Êý£¬parameter¡­listÊÇÓöººÅ·Ö¸ôµÄ±äÁ¿»ò±í´ïʽµÄÐòÁУ¬ËüÃÇÒªÓë¸Ã³ÉÔ±º¯ÊýµÄ¶¨ÒåµÄ²ÎÊý¸öÊý¼°ÀàÐÍÆ¥Åä¡£ÔÚÕâ¸öÀý×ÓÀÎÒÃÇ¿ÉÒÔ¶ÔÈκÎUniversity¶ÔÏóµ÷ÓóÉÔ±º¯ÊýinitÀ´¸ønameºÍcity¸³Öµ¡£ÏÂÃæµÄ³ÌÐò¶Î˵Ã÷ÁËÔõÑùÍê³ÉÕâ¸ö¹¤×÷¡£Universityu=newUniversity£¨£©£»u¡£init£¨¡±±±£¿copy£»´óѧ¡±£»¡±±±£¿copy£»¡±£©£»Õâ¸öÀý×Ó´´½¨ÁËUniversityµÄÒ»¸öʵÀý£¬´æ·ÅÔÚuÖС£Í¨¹ýµã²Ù×÷·ûÀ´µ÷ÓÃÕâ¸öʵÀýµÄinit³ÉÔ±º¯Êý£¬°Ñ¡±±±£¿copy£»´óѧ¡±ºÍ¡±±±£¿copy£»¡±·Ö±ð´«µÝ¸ø²ÎÊýaºÍb¡£ÔÚinit³ÉÔ±º¯ÊýÄÚ²¿£¬nameºÍcityÖ±½ÓÖ¸ÏòuËùÖ¸ÏòµÄ¶ÔÏóµÄʵÀý±äÁ¿¡£°Ñname¸³ÖµÎª¡±±±£¿copy£»´óѧ¡±£¬city¸³ÖµÎª¡±±±£¿copy£»¡±£¬È»ºó·µ»Ø¡£ÔÚÕâ¸öÀý×ÓÀinit±»¶¨ÒåΪÎÞÖµ£¨void£¿copy£»·µ»ØÀàÐÍ¡£ÔÚ½øÐÐÕâ¸ö³ÉÔ±º¯Êýµ÷Óúó£¬uÖ¸ÏòÕâ¸önameÖµºÍcityÖµ¸Ä±äÁ˵ÄUniversity¶ÔÏó¡£
5¡£7thisJavaÓÐÒ»¸öÌØÊâµÄʵÀýÖµ½Ðthis£¬ËüÓÃÀ´ÔÚÒ»¸ö³ÉÔ±º¯ÊýÄÚ²¿Ö¸Ïòµ±Ç°µÄ¶ÔÏó¡£ÔÚÇ°ÃæµÄÀý×ÓÀÎÒÃǵ÷ÓÃu¡£init£¬Ò»£¿copy£»½øÈëinit³ÉÔ±º¯ÊýÄÚ²¿£¬this¾Í»áÖ¸ÏòuËùÖ¸ÏòµÄ¶ÔÏó¡£ÔÚJavaÀÔÚͬһ¸ö·¶Î§¶¨ÒåÁ½¸öÏàͬÃû×ֵľֲ¿±ä
Á¿ÊDz»¿ÉÒԵġ£ÓÐȤµÄÊÇ£¬¾Ö²¿±äÁ¿¡¢³ÉÔ±º¯ÊýµÄ²ÎÊý¿ÉÒÔºÍʵÀý±äÁ¿µÄÃû×ÖÏàͬ¡£Ç°ÃæÎÒÃÇûÓÐÓÃnameºÍcity×÷Ϊ³ÉÔ±º¯ÊýinitµÄ²ÎÊýÃû×Ö£¬ÒòΪÕâÑùËüÃÇÔÚ³ÉÔ±º¯ÊýµÄ·¶Î§Àï¾Í°ÑʵÀý±äÁ¿nameºÍcityÒþ²ØÁË£¬¼´nameÖ¸Ïò²ÎÊýname£¬Òþ²ØÁËʵÀý±äÁ¿name¡£thisÈÃÎÒÃÇ¿ÉÒÔÖ±½ÓÖ¸Ïò¶ÔÏó±¾Éí¡£ÏÂÃæÊÇÁíÒ»¸ö°æ±¾µÄinit£¬ÓÃnameºÍcity×÷Ϊ²ÎÊýÃû×Ö£¬ÓÃthisÀ´½ÓÊÕµ±Ç°¶ÔÏóµÄʵÀý±äÁ¿¡£
voidinit£¨Stringname£»Stringcity£©£ûthis¡£name=name£»this¡£city=city£»£ýÏÂÃæÊÇ´øÓÐеÄinit³õʼ³ÉÔ±º¯ÊýµÄTwoUniversityÀý×Ó¡£classUniversity£ûStringname£»city£»voidinit£¨Stringname£»Stringcity£©£ûthis¡£name=name£»this¡£city=city£»£ý£ýclassTwoUniversityInit£ûpublicstaticvoidmain£¨Stringargs£§£§£©£ûUniversityu1=newUniversity£¨£©£»Universityu2=newUniversity£¨£©£»u1¡£init£¨¡±±±£¿copy£»´óѧ¡±£»¡±±±£¿copy£»¡±£©£»u2¡£init£¨¡±Ç廪´óѧ¡±£»¡±±±£¿copy£»¡±£©£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u1¡£name£«¡±³ÇÊУº¡±£«u1¡£city£©£»system¡£out¡£println£¨¡±´óѧ£º¡±£«u2¡£name£«¡±³ÇÊУº¡±£«u2¡£city£©£»£ý£ý
5¡£8¹¹Ô캯Êý£¨Constructor£©
ÿ´´½¨Ò»¸öÀàµÄʵÀý¶¼È¥³õʼ»¯ËüµÄËùÓбäÁ¿ÊÇ·¦Î¶µÄ¡£Èç¹ûÒ»¸ö¶ÔÏóÔÚ±»´´½¨Ê±¾ÍÍê³ÉÁËËùÓеijõʼ¹¤×÷£¬½«ÊǼòµ¥µÄºÍ¼ò½àµÄ¡£Òò´Ë£¬JavaÔÚÀàÀïÌ᣿copyÁËÒ»¸öÌØÊâµÄ³ÉÔ±º¯Êý£¬½Ð×ö¹¹Ô캯Êý£¨Constructor£¿copy£»¡£Ò»¸ö¹¹Ô캯ÊýÊǶÔÏó±»´´½¨Ê±³õʼ¶ÔÏóµÄ³ÉÔ±º¯Êý¡£Ëü¾ßÓкÍËüËùÔÚµÄÀàÍêÈ«Ò»ÑùµÄÃû×Ö¡£Ò»£¿copy£»¶¨ÒåºÃÒ»¸ö¹¹Ô캯Êý£¬´´½¨¶ÔÏóʱ¾Í»á×Ô¶¯µ÷ÓÃËü¡£¹¹Ô캯ÊýûÓзµ»ØÀàÐÍ£¬¼´Ê¹ÊÇvoidÀàÐÍҲûÓС£ÕâÊÇÒòΪһ¸öÀàµÄ¹¹Ô캯ÊýµÄ·µ»ØÖµµÄÀàÐ;ÍÊÇÕâ¸öÀà±¾Éí¡£¹¹Ô캯ÊýµÄÈÎÎñÊdzõʼһ¸ö¶ÔÏóµÄÄÚ²¿×´Ì¬£¬ËùÒÔÓÃnew²Ù×÷·û´´½¨Ò»¸öʵÀýºó£¬Á¢¿Ì¾Í»áµÃµ½Ò»¸öÇå³þ¡¢¿ÉÓõĶÔÏó¡£ÏÂÃæÕâ¸öÀý×ÓÀÓù¹Ô캯ÊýÈ¡´úÁ˳ÉÔ±º¯Êýinit¡£
classUniversity£ûStringname£»city£»University£¨Stringname£»Stringcity£©
£ûthis¡£name=name£»this¡£city=city£»£ý£ýclassUniversityCreate£ûpublicstaticvoidmain£¨Stringargs£§£§£©£ûUniversityu=newUniversity£¨¡±±±£¿copy£»´óѧ¡±£»¡±±±£¿copy£»¡±£©£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u¡£name£«¡±³ÇÊУº¡±£«u¡£city£©£»£ý£ýnewÓï¾äÖÐÀàÃûºóµÄ²ÎÊýÊÇ´«¸ø¹¹Ô캯ÊýµÄ¡£
5¡£9³ÉÔ±º¯ÊýÖØÔØ
¶ÔÓÚ¼¸¸öÒâÒåÏà½üµÄ³ÉÔ±º¯Êý£¬ÓÐʱʹÓÃÏàͬµÄÃû×Ö±ãÓÚÀí½â¡£Òò´Ë£¬JavaÓïÑÔʵÏÖÁ˳ÉÔ±º¯ÊýÖØÔØ£¬¼´¿ÉÒÔ´´½¨¼¸¸öÃû×ÖÏàͬ¡¢²ÎÊý²»Í¬µÄ³ÉÔ±º¯Êý¡£³ÉÔ±º¯ÊýÖØÔØÌ᣿copy£»ÁËJavaµÄ¶à̬ÐÐΪ¡£ÏÂÃæµÄÀý×ÓÓõ½ÁËÖØÔØ¡£classUniversity£ûStringname£»city£»University£¨Stringname£»Stringcity£©£ûthis¡£name=name£»this¡£city=city£»£ýUniversity£¨£©£ûname=¡±±±£¿copy£»´óѧ¡±£»city=¡±±±£¿copy£»¡±£»£ý£ý
classUniversityCreateAlt£ûpublicstaticvoidmain£¨Stringargs£§£§£©£ûUniversityu=newUniversity£¨£©£»System¡£out¡£println£¨¡±´óѧ£º¡±£«u¡£name£«¡±³ÇÊУº¡±£«u¡£city£©£»£ý£ý
Õâ¸öÀý×Ó´´½¨ÁËÒ»¸öUniversity¶ÔÏ󣬵÷ÓÃÁ˵ڶþ¸ö¹¹Ô캯Êý¡£ÏÂÃæÊÇËüµÄÔËÐнá¹û¡£
C£º¡·javaUniversityCreateAlt´óѧ£º±±£¿copy£»´óѧ³ÇÊУº±±£¿copy£»Ò»¸ö¹¹Ô캯Êý¿ÉÒÔµ÷ÓÃÁíÒ»¸ö¹¹Ô캯ÊýÀ´´´½¨ÊµÀý¡£ÀýÈ磺
classUniversity£ûStringname£»city£»University£¨Stringname£»Stringcity£©
£ûthis¡£name=name£»this¡£city=city£»£ýUniversity£¨£©£ûthis£¨¡±±±£¿copy£»´óѧ¡±£»¡±±±£¿copy£»¡±£©£»£ý£ý
µÚ¶þ¸ö¹¹Ô캯Êýµ÷ÓÃÁ˵ÚÒ»¸ö¹¹Ô캯ÊýÀ´Íê³ÉʵÀýµÄ³õʼ»¯¡£ÄãÒ²¿ÉÒÔÓÃÖØÔØÀ´´´½¨Ò»°ãµÄ³ÉÔ±º¯Êý¡£ÏÂÃæÕâ¸öÀý×ÓÀïÓÐUniversityÀàµÄÁ½¸ö°æ±¾µÄsamecity³ÉÔ±º¯Êý¡£samecityÅжÏÒ»¸ö´óѧÊÇ·ñÔÚÒ»¸ö³ÇÊÐÀï»òÒ»¸ö´óѧºÍÁíÒ»¸ö´óѧÊÇ·ñÔÚͬһ¸ö³ÇÊÐÀï¡£Ò»¸ö³ÉÔ±º¯ÊýÓÃcity×÷²ÎÊý£¬ÁíÒ»¸öÓÃUniversity¶ÔÏó×÷²ÎÊý¡£
classUniversity£ûStringname£»city£»University£¨Stringname£»Stringcity£©
£ûthis¡£name=name£»this¡£city=city£»£ýbooleansamecity£¨Stringcity£©£ûif
£¨city¡£equals£¨this¡£city£©£©returntrue£»elsereturnfalse£»£ýboolean
samecity£¨Universityu£©£ûreturnsamecity£¨u¡£city£©£»£ý£ý
classUniversityCity£ûpublicstaticvoidmain£¨Stringargs£§£§£©£ûString
city=¡±ÉϺ£¡±£»Universityu1=newUniversity£¨¡±±±£¿copy£»´óѧ¡±£»¡±
±±£¿copy£»¡±£©£»Universityu2=newUniversity£¨¡±Ç廪´óѧ¡±£»¡±±±£¿copy£»¡±£©£»
System¡£out¡£println£¨¡±u1=¡±£«u1¡£name£«¡±£»¡±£«u1¡£city£©£»
System¡£out¡£println£¨¡±u2=¡±£«u2¡£name£«¡±£»¡±£«u2¡£city£©£»
System¡£out¡£println£¨¡±city=¡±£«city£©£»
System¡£out¡£println£¨¡±u1¡£samecity£¨u2£©=¡±£«u1¡£samecity£¨u2£©£©£»
System¡£out¡£println£¨¡±u1¡£samecity£¨city£©=¡±£«u1¡£samecity£¨city£©£©£»£ý£ý
ÏÂÃæÊǸóÌÐòµÄÔËÐнá¹û¡£
C£º¡·javaUniversityCityu1=±±£¿copy£»´óѧ£»±±£¿copy£»u2=Ç廪´óѧ£»±±£¿copy£»city=ÉϺ£u1¡£samecity£¨u2£©=trueu1¡£samecity£¨city£©=false
5¡£10¼Ì³Ð
µÚ¶þ¸ö»ù±¾µÄÃæÏò¶ÔÏó»úÖÆÊǼ̳С£¼Ì³ÐÊǹØÓÚÓвã´Î¹ØϵµÄÀࣿreg£»¼äµÄ¸ÅÄî¡£Ò»¸öÀàµÄºó´ú¿ÉÒԼ̳ÐËüµÄ×æÏȵÄËùÓбäÁ¿ºÍ³ÉÔ±º¯Êý£¬¾ÍÏó´´½¨×Ô¼ºµÄÒ»Ñù¡£Ò»¸öÀàµÄÖ±½Ó¸¸Ç×½Ð×öËüµÄ³¬Àࣨsuperclass£¿copy£»¡£Ò»£¿copy£»Äã´´½¨ÁËÒ»¸öÏóUniversityÕâÑùµÄÀ࣬´´½¨ËüµÄ×ÓÀàÊǺܼòµ¥µÄ¡£Ò»¸öÀàµÄ×ÓÀàÊÇËüµÄ¼Ì³ÐÁËʵÀý±äÁ¿ºÍ³ÉÔ±º¯ÊýµÄÌØÊâµÄ°æ±¾¡£ÔÚÕâ¸öÀý×ÓÀÎÒÃÇ°ÑUniversityÀàÅÉÉúΪº¬ÓнÐ×öcountryµÄµÚÈý¸öÔªËصÄ×ÓÀà¡£
classUniversityWorldextendsUniversity£ûStringcountry£»UniversityWorld£¨Stringname£»Stringcity£»Stringcountry£©£ûthis¡£name=name£»this¡£city=city£»this¡£country=country£»£ýUniversityWorld£¨£©£ûthis£¨¡±±±£¿copy£»´óѧ¡±£»¡±±±£¿copy£»¡±£»¡±Öйú¡±£©£»£ý£ý
¹Ø¼ü´ÊextendsÓÃÀ´±íʾÎÒÃÇÒª´´½¨UniversityµÄ×ÓÀà¡£nameºÍcity²»ÐèÔÙÔÚUniversityWorldÖнøÐÐÉùÃ÷£¬ÒòΪËüÃÇÊÇ´ÓUniversityÖм̳еġ£JavaÔÊÐíÔ
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿!
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡