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

Effective Java Item10

Effective Java 2nd Edition Reading Notes
Item10: Always override toString
×ÜÊǸ²¸ÇtoString·½·¨
 
java.lang.ObjectµÄtoString·½·¨µÄ˵Ã÷Ϊ£º
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
java.lang.ObjectµÄtoString·½·¨·µ»ØµÄÊÇÀàµÄÃû×Ö£¬¼ÓÉÏ@·ûºÅ£¬È»ºóÊÇÒ»¸öÎÞ·ûºÅµÄ16½øÖÆÊý(¶ÔÏóµÄhash codeÖµ)£¬ÕâÑùµÄtoString·½·¨ÏÔÈ»´«´ïµÄÐÅÏ¢»¹²»¹»¡£¶øtoString·½·¨µÄ˵Ã÷Öаüº¬ÁË“½¨ÒéËùÓеÄ×ÓÀà¶¼¸²¸ÇÕâ¸ö·½·¨”¡£
 
toString·½·¨ÔÚprintln£¬printf£¬×Ö·û´®Á¬½Ó£¬ÒÔ¼°assert¶ÏÑÔÖУ¬ÒÔ¼°ÔÚµ÷ÊÔÆ÷ÖУ¬¶¼±»µ÷Óá£
 
toString·½·¨Ó¦¸Ã°üº¬ËùÓжÔÏóµÄÖØÒªÐÅÏ¢¡£
 
ÁíÍâÒ»¸öÎÊÌâÊÇ£ºÊÇ·ñÐèÒª¶ÔtoString·µ»ØµÄÖµ½øÐÐÖ¸¶¨¸ñʽ¡£
Ö¸¶¨¸ñʽµÄºÃ´¦ÔÚÓÚËü¿ÉÒÔ×öΪһ¸ö±ê×¼£¬²»»á´øÓÐÆçÒ壬²¢ÇҿɶÁÐԺá£Õâ¸ö·µ»ØÖµ¿ÉÒÔÓÃÓÚÊäÈë»òÕßÊä³ö£¬³Ö¾Ã»¯µÄ¿É¶Á¶ÔÏó(xmlÎļþ)¡£Èç¹ûÖ¸¶¨¸ñʽµÄ»°£¬×îºÃÔÙÌṩһ¸ö¹¤³§ÀàÓÃÓÚ¸ù¾ÝString¹¹ÔìʵÀý¡£
Ö¸¶¨¸ñʽµÄȱµãÔÚÓÚËüÊǺͽӿÚÒ»Ñù£¬Ò»µ©Ö¸¶¨ÁË£¬¾Í²»Äܸı䣬ÒòΪ¿ÉÄÜÓÐÍⲿʹÓÃËü£¬Ò»µ©Ëü¸Ä±äÁË£¬Íⲿ´úÂ뽫ÎÞ·¨Ê¹Óá£
Ò»µ©ÐèÒªÖ¸¶¨¸ñʽ£¬ÄÇôҪ׼ȷµÄ¶¨Òå²¢½øÐÐÎĵµ×¢ÊÍ£º
/**
 * Returns the string representation of this phone number.
 * The string consists of fourteen characters whose format
 * is "(XXX) YYY-ZZZZ", where XXX is the area code, YYY is
 * the prefix, and ZZZZ is the line number.  (Each of the
 * capital letters represents a single decimal digit.)
 *
 * If any of the three parts of this phone numb


Ïà¹ØÎĵµ£º

java µ÷ÓÃmysql¿Í»§¶Ëµ¼È룬µ¼³öÊý¾Ý

 ×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë 
/**  
 * µ¼ÈëÊý¾Ý  
  * @param  ½Å±¾µÄµØÖ·ºÍÃû³Æ  
 * @return ÊÇ·ñ³ ......

javaÊ±Çø½â¾ö·½°¸

 tomcatÆô¶¯web·þÎñµÄʱºò×ÜÊÇ»áÓÐ8СʱµÄʱ²î,
×ÁÄ¥Á˺þÃ,×î¼òµ¥µÄ°ì·¨¾ÍÊÇ
ÕÒµ½Îļþ¼Ðjdk1.6.0_07\jre\lib\zi\Etc
ÕâÀï±ß¶¼ÊÇÒ»Ð©Ê±ÇøÎļþGTM+1,GTM+2,GTM+3....
±¸·ÝÒ»·ÝEtc
¿½±´N·ÝGTM+8Îļþ(ÖйúµÄÊ±ÇøÊÇGTM+8)
°ÑGMT+8ÎļþÃû¸Ä³ÉGTM+1,GTM+2,GTM+3....
¸²¸ÇµôÔ­À´µÄEtcÀï±ßµÄÎļþ
ÖØÆôtomcatÎÊÌâ½â¾ö ......

JAVA»·¾³±äÁ¿ÉèÖÃ

¾ÙÀý×Ó˵Ã÷Ò»ÇС£
JAVA_HOME£º C:\j2sdk1.4.2_13
 
Path£º         C:\j2sdk1.4.2_13\bin;
Classpath£º.;JAVA_HOME\lib\tools.jar ; JAVA_HOME\lib\dt.jar;
                 &n ......

JAVA List to Array,Array to List

 1.Listת»»³ÉΪÊý×é¡££¨ÕâÀïµÄListÊÇʵÌåÊÇArrayList)
µ÷ÓÃArrayListµÄtoArray·½·¨¡£
Àý£ºString[] arr = (String[])list.toArray(new String[size]);
2.Êý×éת»»³ÉΪList¡£
µ÷ÓÃArraysµÄasList·½·¨¡£
Àý£ºList stooges = Arrays.asList("Larry", "Moe", "Curly"); ......

JDKÖаüº¬µÄ³£ÓÃJavaµ÷ÊÔ¹¤¾ß

1  JDK5.0°üÀ¨µÄµ÷ÊÔ¹¤¾ß
ÎÒÃÇÔÚÕâÀï¶ÔJDK5.0µÄµ÷ÊÔ¹¤¾ß×ö´óÖµĸÅÄîÐԵĽéÉÜ£¬È»ºóÏ£Íûͨ¹ý½éÉÜÎÒ×Ô¼ºÔÚʵ¼Ê¹¤×÷ÖÐʹÓÃÕâЩ¹¤¾ß½â¾öÎÊÌâµÄʵÀýÀ´Èôó¼Ò¶ÔÕâЩ¹¤¾ßÓиüÉîÈëµÄÁ˽⡣
 
¡¡JDK5.0ÀïÃæ¼ÓÈëÁËjstack, jconsole, jinfo, jmap, jdb, jstat, jps, ÏÂÃæ¶ÔÕâЩ¹¤¾ß×ö¼òµ¥½éÉÜ£º
¡¡jstack -- Èç¹ûjava³Ì ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ