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

Effective Java ѧϰ±Ê¼Ç£¨5£©

¾¡Á¿¸´ÓöÔÏ󣬶ø²»ÊÇ´´½¨ÐµĶÔÏó£¬ÌرðÊǵ±Ò»¸ö¶ÔÏóÊÇimmutable£¨²»¿É¸Ä±ä£©µÄʱºò¡£
ÈçString¶ÔÏó£¬
String s= new String(“String”);   ǧÍò²»ÒªÕâÑù×ö£¬ÒòΪÕâÀïʵ¼ÊÉÏ´´½¨ÁËÁ½¸ö¶ÔÏó¡£
Òª±ÜÃâ³öÏÖÕâÑùµÄÇé¿ö£¬
1ÊÇ¿ÉÒÔÓþ²Ì¬¹¤³§º¯Êý£¬À´½â¾ö£¬ÈçÀà¿âÖеÄBoolean.valueOf(“true”)£¬ÕâÖÖ·½Ê½ÒªÓÅÓÚnew Boolean(“true”);
2.ÊǾ¡Á¿¸´ÓöÔÏó¡£
¿´ÊéÖеÄÀý×Ó¡£
public class Person {
          private final Date birthDate;
          public boolean isBabyBoomer() {
              Calendar gmtCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
               gmtCal.set(1946, Calendar.JANUARY, 1, 0, 0, 0);
               Date boomStart = gmtCal.getTime();
               gmtCal.set(1965, Calendar.JANUARY, 1, 0, 0, 0);
               Date boomEnd = gmtCal.getTime();
               return birthDate.compareTo(boomStart) >= 0 && birthDate.compareTo(boomEnd) < 0;
         }
}
ÕâÀÿ´Îµ÷ÓÃisBabyBoomer¾Í»á´´½¨Á½¸öData¶ÔÏó£¬Ò»¸öCalendar¶ÔÏóºÍTimeZone¶ÔÏó.
¸Ä½ø°æ£º
class Person {
                    private final Date birthDate;
                   
             private static final Date BOOM_START;
    &nb


Ïà¹ØÎĵµ£º

Java¶àÏ̱߳à³Ì¾­Ñé

²»¹ÜÎÒÊǶàôϲ»¶JAVAµ«ÊÇ£¬´Óʵ¼Ê¿ª·¢½Ç¶È½²£¬JavaµÄ¶àÏß³ÌȷʵûÓÐC++ºÃʹ¡£
±íÏÖÔÚ£º
1.JavaûÓÐÈ«¾Ö±äÁ¿£»
2.Java µÄÏß³ÌÖ®¼äµÄͨÐűȽϲC++ÌṩÁ˶àÖÖͨÐÅ·½Ê½£»
3.JavaµÄÊý¾Ýͬ²½ÊÇͨ¹ýsynchronizedÀ´ÊµÏÖ£¬µ«ÊÇ»ù±¾ÉϵÈÓÚ½»¸øÁËÐéÄâ»úÀ´Íê³É£¬¶øC++ÓкܶàÖÖ£ºÁÙ½çÇø¡¢»¥³âÌåµÈ¡£
4. JavaµÄ¶àÏß³Ìrun·½· ......

java¶àÏ̱߳à³ÌÌå»á

ÔÚ Java ³ÌÐòÖÐʹÓöàÏß³ÌÒª±ÈÔÚ C »ò C++ ÖÐÈÝÒ׵ö࣬ÕâÊÇÒòΪ Java ±à³ÌÓïÑÔÌṩÁËÓïÑÔ¼¶µÄÖ§³Ö¡£±¾ÎÄͨ¹ý¼òµ¥µÄ±à³ÌʾÀýÀ´ËµÃ÷ Java ³ÌÐòÖеĶàÏß³ÌÊǶàôֱ¹Û¡£¶ÁÍê±¾ÎÄÒÔºó£¬Óû§Ó¦¸ÃÄܹ»±àд¼òµ¥µÄ¶àÏ̳߳ÌÐò¡£
¡¡¡¡ÎªÊ²Ã´»áÅŶӵȴý£¿
¡¡¡¡ÏÂÃæµÄÕâ¸ö¼òµ¥µÄ Java ³ÌÐòÍê³ÉËÄÏî²»Ïà¹ØµÄÈÎÎñ¡£ÕâÑùµÄ³ÌÐòÓе¥¸ö¿ØÖ ......

Java¶àÏ̱߳à³ÌÏê½â

Ò»£ºÀí½â¶àÏß³Ì
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆÎªÒ»¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£
Ïß³ÌÓÖ³ÆÎªÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖÐµÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨÐÅÔ¶½Ï½ø³Ì¼òµ¥¡£ ......

Effective Java ѧϰ±Ê¼Ç£¨2£©

ÓÐʱ£¬ÎÒÃÇÔÚдһ¸ö¹¹Ô캯Êýʱ£¬¾­³£ÒòΪËü°üº¬ÖÚ¶àµÄ²ÎÊý¶ø¿àÄÕ,Õâʱ¿ÉÒÔ¿¼ÂÇÓÃBuilderģʽÀ´´´½¨¶ÔÏó¡£
È磬ÎÒÃÇÒªÉè¼ÆÒ»¸öÓªÑø³É·ÝµÄÀ࣬°üº¬ÄÜÁ¿£¬µ°°×ÖÊ£¬Ö¬·¾£¬¸Æ£¬Ìú£¬Ð¿£¬Î¬ÉúËØA, άÉúËØB1 ... µÈ£¬µ«ÔÚ¹¹ÔìµÄʱºò£¬²»Ò»¶¨Ã¿´Î¶¼ÐèÒªÕâЩ²ÎÊý£¬Èç¸Æ£¬Ìú£¬Ð¿ºÍάÉúËØµÈÊÇ¿ÉÑ¡µÄ£¬ÎªÁËÊÊÓ¦¶àÖÖ¿ÉÄܵĴîÅ䣬±È½Ïԭʼ ......

Effective Java ѧϰ±Ê¼Ç£¨3£©

ÔÚʵÏÖsingletonģʽʱ£¬ÎÒÃÇÓÐÒÔϼ¸ÖÖ·½·¨¡£
1. public static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯Êý¡£
public class Singleton{
            public static final Singleton INSTANCE = new Singleton();
        & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ