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

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

 ÓÐʱ£¬ÎÒÃÇÔÚдһ¸ö¹¹Ô캯Êýʱ£¬¾­³£ÒòΪËü°üº¬ÖÚ¶àµÄ²ÎÊý¶ø¿àÄÕ,Õâʱ¿ÉÒÔ¿¼ÂÇÓÃBuilderģʽÀ´´´½¨¶ÔÏó¡£
È磬ÎÒÃÇÒªÉè¼ÆÒ»¸öÓªÑø³É·ÝµÄÀ࣬°üº¬ÄÜÁ¿£¬µ°°×ÖÊ£¬Ö¬·¾£¬¸Æ£¬Ìú£¬Ð¿£¬Î¬ÉúËØA, άÉúËØB1 ... µÈ£¬µ«ÔÚ¹¹ÔìµÄʱºò£¬²»Ò»¶¨Ã¿´Î¶¼ÐèÒªÕâЩ²ÎÊý£¬Èç¸Æ£¬Ìú£¬Ð¿ºÍάÉúËصÈÊÇ¿ÉÑ¡µÄ£¬ÎªÁËÊÊÓ¦¶àÖÖ¿ÉÄܵĴîÅ䣬±È½ÏԭʼµÄ°ì·¨¾ÍÊDzÉÓÃtelescoping constructorģʽ£¬Àý×ÓÈçÏ¡£
public class Nutrition
{
          private int calories;
          private int protein;
          private int fat;
          private int ca;
          private int fe;
          private int Va;
          private int Vb;
          ...
          public Nutrition(int cal, int pro){...}
          public Nutrition(int cal, int pro, int fat){...}
          public Nutrition(int cal, int pro, int fat, int ca){...}
          public Nutrition(int cal, int pro, int fat, int ca, int fe){...}
          public Nutrition(int cal, int pro, int fat, int ca, int fe, int ){...}
          public Nutrition(int cal, int pro, int fat, int ca, int fe, int Va){...}
           .......
}
ÕâÖÖ·½·¨µÄȱµãºÜÃ÷ÏÔ£¬Ò»¸öº¯ÊýµÄ²ÎÊýÒ»µ©³¬¹ý3¸ö£¬Óû§¾ÍºÜÈÝÒ×°Ñ˳Ðò¸ã»ì£¬¶ø¸ü±­¾ßµÄÊÇÕâÖÖÇé¿ö±àÒëÆ÷ÎÞ·¨Ê¶±ð£¬·Ç³£²»Òײé´í¡£
µÚ¶þÖÖ·½·¨ÊÇJavaBeanģʽ¡£
         
public class Nutrition
{
 


Ïà¹ØÎĵµ£º

ʹÓÃC++¶ÔjavaµÄclassloader½øÐÐÄ£Äâ

ת×Ô£ºÊ¹ÓÃC++¶ÔjavaµÄclassloader½øÐÐÄ£Äâ
Ò»Ö±ÒÔÀ´£¬¾õµÃjavaµÄclassloaderºÜ²»´íµÄ£¬×ö²úÆ·µÄ»°£¬¿ÉÒÔ½«»ù±¾µÄ×öÏÂÀ´ºó£¬½«À©Õ¹Í¨¹ýclassloaderµÄ·½Ê½À´×ö£¬½«¸üеIJ¹
¶¡Ê¹ÓÃclassloaderÀ´×ö£¬ÔÚʹÓÃjavaµÄÍøÂçÓÎÏ·ÖУ¬¿ÉÒÔ½«À©Õ¹Í¨¹ýclassloaderµÄ»úÖÆ£¬ÊµÏÖ¶¯Ì¬µÄ¸üУ¬Ê¡µÄÿ´Î¸üÐÂÒªÖØÐÂÏÂÔØ
¿Í»§¶Ë£¬ÔÚÊÖ»úÉÏ¿É ......

javaµÄ»ù±¾Ë¼Ïë

³     Java ÓïÑÔÖУ¬¶Ô¸÷ÖÖ±äÁ¿¡¢·½·¨ºÍÀàµÈÒªËØÃüÃûʱʹÓõÄ×Ö·ûÐòÁгÆΪ±êʶ·û¡£
      --·²ÊÇ×Ô¼º¿ÉÒÔÆðÃû×ֵĵط½¶¼½Ð±êʾ·û£¬¶¼×ñÊرêʾ·ûµÄ¹æÔò¡£
³     Java ±êʶ·ûÓÐÈçÏÂÃüÃû¹æÔò£º
–     ±êʶ·ûÓÉ×Öĸ¡ ......

JAVAʵÏֵĴóÕûÊý¼Ó·¨

public class Test{ 
  public static String addBigNum(String str1,String str2){
     //ÕÒ³öÁ½×Ö·û´®µÄ³¤¶Ì£¬·½±ãºó±ßÒýÓã»
     String longer = str1.length() > str2.length()? str1 : str2;
     String shorter = str1.length( ......

JAVA¼ÓÃÜËã·¨

MD5Ëã·¨ÊÇÒ»Öַdz£ÓÅÐãµÄ¼ÓÃÜËã·¨¡£
MD5¼ÓÃÜËã·¨Ìص㣺Áé»îÐÔ¡¢²»¿É»Ö¸´ÐÔ¡£
       ½éÉÜMD5¼ÓÃÜËã·¨»ù±¾Çé¿öMD5µÄÈ«³ÆÊÇMessage-Digest Algorithm 5£¬ÔÚ90Äê´ú³õÓÉMITµÄ¼ÆËã»ú¿ÆѧʵÑéÊÒºÍRSA Data Security Inc·¢Ã÷£¬¾­MD2¡¢MD3ºÍMD4·¢Õ¹¶øÀ´¡£
Message-Digest·ºÖ¸×Ö½Ú´®(Message)µÄHas ......

JAVA¼ÓÃÜËã·¨»ã×ÜÒ»

1. MD5¼ÓÃÜ£¬³£ÓÃÓÚ¼ÓÃÜÓû§ÃûÃÜÂ룬µ±Óû§Ñé֤ʱ¡£
¡¡ ¡¡protected byte[] encrypt(byte[] obj) ...{
¡¡¡¡try ...{
¡¡¡¡MessageDigest md5 = MessageDigest.getInstance("MD5");
¡¡¡¡md5.update(obj);
¡¡¡¡return md5.digest();
¡¡¡¡} catch (NoSuchAlgorithmException e) ...{
¡¡¡¡e.printStackTrace();
¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ