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

¡¶Effective javaÖÐÎĵÚ2°æ¡·¶ÁÊé±Ê¼Ç1

µÚ2Ìõ£ºÓöµ½¶à¸ö¹¹ÔìÆ÷²ÎÊýʱҪ¿¼ÂÇÓù¹½¨Æ÷
ij¸öÀàµÄÊôÐԽ϶࣬³õʼ»¯µÄʱºòÓÖÓÐһЩÊDZØÐë³õʼ»¯µÄ£¬¶øÇÒÀàÐÍÓÐÐÎͬ£¬
±ÈÈçnew Contact("ÐÕÃû","ÏÔʾÃû","ÊÖ»úºÅ","·ÉÐźÅ","ËùÔÚµØ",ÄêÁä,ÐÔ±ð);
Ç°5¸öÊôÐÔÊÇString ÀàÐÍ£¬ºó2¸öÊÇintÀàÐÍ£¬ÔÚÌîд¹¹Ôì·½·¨µÄʱºòºÜÈÝÒ×Ìîд´í룬»òÕßÉÙÌîд£¬»òÕߵߵ¹ÁËÊôÐÔ£¬
ÈçÏ·½·¨¿ÉÒÔ¼õÉÙÕâÖÖ´íÎó·¢ÉúµÄ¼¸ÂÊ£¬
Contact contact = new Contact();
contact.setName("ÐÕÃû");
contact.setDisplayName("ÏÔʾÃû");
contact.setPhoneNumber("ÊÖ»úºÅ");
contact.setFetionNumber("·ÉÐźÅ");
contact.setHometown("ËùÔÚµØ");
contact.setAge(23);
contact.setGender(0);
ÕâôдÊÇͨ³£µÄ×ö·¨£¬¿´ÆðÀ´»¹²»¹»ÇåÎú£¬ÎÒÃÇÔÚÿ¸öset·½·¨ÀïretrunÒ»¸öContactÀàÐÍ£¬±ÈÈç
public Contact setName(String name)
{
this.name = name;
return this;
}
ÕâÑùÉÏÃæµÄ¹¹ÔìContactµÄ´úÂë¾Í¿ÉÒÔÕâôдÁË
Contact contact = new Contact() .setName("ÐÕÃû")
.setDisplayName("ÏÔʾÃû")
.setPhoneNumber("ÊÖ»úºÅ")
.setFetionNumber("·ÉÐźÅ")
.setHometown("ËùÔÚµØ")
.setAge(23)
.setGender(0);
ÕâÑùдÊDz»ÊǸüÇåˬÁË£¡ÊôÐÔ²»»áÔÙÌîд´íÎóÁË£¡¶øÇÒÔĶÁ´úÂëµÄʱºòҲһĿÁËÈ»£¬¶¼¸øContact³õʼ»¯ÁËÄÇЩÊôÐÔ£¬ºÍÊôÐÔµÄÖµÊÇʲô£¡
µÚ3Ìõ£ºÓÃ˽Óй¹ÔìÆ÷»òÕßö¾ÙÀàÐÍÇ¿»¯SingletonÊôÐÔ
½¨ÒéʹÓÃÈçÏ·½·¨´´½¨µ¥ÀýÀà
public final class Elvis
{
private static Elvis INSTANCE;
private Elvis(){};
synchronized public static Elvis getInstance()
{
if( INSTANCE == null )
{
INSTANCE = new Elvis();
}
return INSTANCE;
}
//Ö´ÐÐÆäËû²Ù×÷
private Object readResolve()
{
return INSTANCE;
}
}
ÕâÖÖ¹¹½¨·½·¨ºÃ´¦£¬×é³ÉÀàµÄ³ÉÔ±ÉùÃ÷ºÜÇå³þµØ±íÃ÷ÁËÕâ¸öÀàÊǸöSingleton£¬²¢ÇÒÒ²½â¾öÁËINSTANCEµÄͬ²½ÎÊÌ⣬
ûÓб©Â¶¹²ÓеÄINSTANCE±äÁ¿£¬ÕâÑù¸üÓÐÁ¦ÓÚÒþ²ØÀàµÄÄÚ²¿ÊµÏÖ£¬
ÁíÍ⣬¸Ä×ö·¨Ò²ºÜÈÝÒ׾ͿÉÒÔÐ޸ijɷǵ¥Àýģʽ£¬¼ÓÉϵÄreadResolve·½·¨¿ÉÒÔ±£Ö¤·´ÐòÁл¯Ê±Ò²ÊÇͬһ¸ö¶ÔÏó¡£

µÚ4Ìõ£ºÍ¨¹ý˽Óй¹ÔìÆ÷Ç¿»¯²»¿ÉʵÀý»¯µÄÄÜÁ¦
ÎÒÃÇÈí¼þÖг£Óõij£Á¿¼¯(Constants)£¬¹¤¾ß¼¯(Tool,Utility)¶¼Ó¦¸ÃÊDz»¿ÉʵÀý»¯µÄÀ࣬ÄÇôËûÃÇÓ¦¸ÃÈçϹ¹½¨
public final class


Ïà¹ØÎĵµ£º

JAVA»ù´¡ÃæÊÔÌâ4

96¡¢JAVAÓïÑÔÈçºÎ½øÐÐÒì³£´¦Àí£¬¹Ø¼ü×Ö£ºthrows,throw,try,catch,finally·Ö±ð´ú±íʲôÒâÒ壿ÔÚtry¿éÖпÉÒÔÅ׳öÒì³£Âð£¿
Javaͨ¹ýÃæÏò¶ÔÏóµÄ·½·¨½øÐÐÒì³£´¦Àí£¬°Ñ¸÷ÖÖ²»Í¬µÄÒì³£½øÐзÖÀ࣬²¢ÌṩÁËÁ¼ºÃµÄ½Ó¿Ú¡£ÔÚJavaÖУ¬Ã¿¸öÒì³£¶¼ÊÇÒ»¸ö¶ÔÏó£¬ËüÊÇThrowableÀà»òÆäËü×ÓÀàµÄʵÀý¡£µ±Ò»¸ö·½·¨³öÏÖÒì³£ºó±ãÅ׳öÒ»¸öÒì³£¶ÔÏó£¬ ......

JavaÓÅ»¯±à³Ì

1.       ÔÚCÓïÑÔÖУ¬ÎÒÃÇͨ³£Ï°¹ß°ÑÐèÒªµÄ¶ÔÏóÉêÃ÷·ÅÔÚº¯ÊýµÄ¿ªÍ·£¬µ«ÆäʵÕâÊÇ°×°×ÀË·ÑÁËÄڴ棬ÔÚJavaÖУ¬²»µ½ÐèÒªµÄʱºò£¬Çë²»Òª´´½¨¶ÔÏó¡£
2.       À¬»ø»ØÊջ᲻¶¨ÆÚµÄËÑË÷ÒѾ­Ã»ÓÐÓõĶÔÏó£¬È»ºóÊͷŶÔÏóµÄÄڴ棬µ«ÕâÖÖËÑË÷ÊDZȽϺÄ×ÊÔ´µÄ¡£ÎªÌá¸ßЧÂÊ£ ......

String in Java

 ÖÚËùÖÜÖª£¬StringÊÇÓÉ×Ö·û×é³ÉµÄ´®£¬ÔÚ³ÌÐòÖÐʹÓÃƵÂʺܸߡ£JavaÖеÄStringÊÇÒ»¸öÀ࣬¶ø²¢·Ç»ù±¾Êý¾ÝÀàÐÍ¡£ ²»¹ýËýÈ´²»ÊÇÆÕͨµÄÀàŶ£¡£¡£¡
¡¾¾µÍ·1¡¿ String¶ÔÏóµÄ´´½¨
   1¡¢¹ØÓÚÀà¶ÔÏóµÄ´´½¨£¬ºÜÆÕͨµÄÒ»ÖÖ·½Ê½¾ÍÊÇÀûÓù¹ÔìÆ÷£¬StringÀàÒ²²»ÀýÍ⣺
        & ......

´ø×Åjavaѧpython

1. pythonÊÇÒ»ÖÖÈõÀàÐ͵Ľű¾ÓïÑÔ£¬ÔÚ¸ø±äÁ¿¸³ÖµÊÇÎÞÐèÖ¸¶¨±äÁ¿µÄÀàÐÍ£¬ÀýÈ磺
x=1                        #£¨ÕûÐÍ£©-------·¶Î§ÔÚ-2^31->2^31
x=2345L     &n ......

JAVAÀàÎļþ°æ±¾(class version)ÓëJDK¶ÔÓ¦¹Øϵ

Ò»¸öjavaµÄclassÎļþÊÇÒ»¸ö¶þ½øÖÆÎļþ£¬ÆäÖÐÇ°Ëĸö×Ö½ÚÊÇmagic룬µÚÎåµ½µÚÁù¸ö×Ö½Ú¶ÔÓ¦ÓÚminorºÍmajor£¬ÏÂÃæÊÇÕâ¸öÀàÎļþ°æ±¾ÓëJDKµÄ¶ÔÓ¦¹Øϵ¡£classÎļþµÄminorºÍmajor¿ÉÒÔͨ¹ýultraeditÀ´²é¿´£¬»ò×Ô¼º±à³ÌµÈ¡£
major minor Java platform version
45 3 1.0
45 3 1.1
46 0 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ