Effective java ´úÂëÓÅ»¯ÊµÀý
package chape7;
/**
* 檢²é參數µÄÓÐЧÐÔ
* 當編寫·½·¨»òÕß構ÔìÆ÷時£¬應該¿¼慮ËûµÄ參數ÓÐʲ÷áÏÞÖÆ 應該°É這ЩÏÞÖÆ寫ÔÚÎÄ檔ÖУ¬並ÇÒÔÚ這個·½·¨µÄ開頭處£¬Í¨過顯ʾµÄ檢²é
* 來實Ê©這ЩÏÞÖÆ¡£養³É這樣µÄ習慣ºÜÖØÒª
* 當ÅÐ斷Ò»個數據µÄºÏ·¨ÐÔµÄ時ºò¾ÍÒª拋³ö異³£¡£ 這裡¾ÍÉæ¼°µ½異³£ µÚ¾ÅÕ 60條£º優ÏÈʹÓÃ標準µÄ異³£ ¾ÍÊÇjava×Ô帶µÄ異³£
* 這Ò²ÊÇÒ»種類µÄÖØÓõıí現£»
* ³£ÓõÄÒì³££º
* IllegalArgumentException ·ÇnullµÄ²ÎÊýÊýÖµ²»ÕýÈ·£»´«ÈëµÄ²ÎÊý²»ºÏ·¨£»
* IllegalStateException ¶ÔÓÚ·½·¨µ÷ÓöøÑÔ£¬¶ÔÏó״̬²»ºÏ·¨±ÈÈçÃþ¸ö¶ÔÏóÔÚ±»ÕýÈ·µÄ³õʼ»¯Ö®Ç°¾Íµ÷Óà »áÅ׳öÕâ¸öÒì³£
* NullPointerException ¿ÕÖ¸ÕëÒì³£ ÔÚ½ûÖ¹nullµÄÇé¿öÏÂʹÓÃÁËnullÖµ£»
* IndexOutOfBoundsException ϱê²ÎÊýÔ½½ç
* ConcurrentModificationException µ±·½·¨¼ì²âµ½¶ÔÏóµÄ²¢·¢Ð޸ģ¬µ«²»ÔÊÐíÕâÖÖÐÞ¸Äʱ£¬Å׳ö´ËÒì³£¡£
* UnsupportedOperationException µ±²»Ö§³ÖÇëÇóµÄ²Ù×÷ʱ£¬Å׳ö¸ÃÒì³£
* @author lee
*
*/
public class Chape38 {
/**
* @param args
*/
public static void main(String[] args) {
Nuter nu = new Nuter.Builder (200,2).fat(-1).sodium(20).build();
}
}
class Nuter
{
private final int size;
private final int sering;
private final int fat;
private final int sodium;
public static class Builder
{
//ÕâÁ½¸ö²ÎÊýʱ±ØÐëµÄ²ÎÊý
private final int size;
private final int sering;
//ÏÂÃæÊÇ¿ÉÑ¡µÄ²ÎÊý ÉèÖÃÁËĬÈÏÖµ
private int fat = 0;
private int sodium = 0;
public Builder (int size ,int sering)
{
this.sering = sering;
this.size = size;
}
public Builder fat (int val)
{
/**
* ¶ÏÑÔµÄʹÓÃ
* ÔÚ這裡ÅÐ
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
C++ÓëJava»ù±¾Êý¾ÝÀàÐͼ°ËùÕ¼ÓÃÄÚ´æ¿Õ¼ä±È½Ï
----------------C++
----------- ------------Java
----------
(01)bool-------- ......
ѧϰjavaµÄ30¸öÄ¿±ê----Èç¹ûÕâ30ÌõÄã×öµÄ²î²»¶àÁË£¬jAVAˮƽ¾Íµ±È»²»ÓÃ˵ÁË£¬ºÃºÃŬÁ¦°É
1.ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÊ®·ÖÁ˽âUML£¬ÓÈÆäÊÇclass£¬object£¬interactionÒÔ¼°statediagrams¡£
¡¡¡¡2.ÄãÐèҪѧϰJAVAÓïÑԵĻù´¡ÖªÊ¶ÒÔ¼°ËüµÄºË ......
ÔÚJAVAÖУº
1. º¯ÊýÖØÔØÊÇÒ»¸öÀàÖÐÉùÃ÷Á˶à¸öͬÃûµÄ·½·¨£¬µ«Óв»Í¬µÄ²ÎÊý¸öÊýºÍ²ÎÊýÀàÐÍ¡£
2. º¯ÊýÖع¹ÊÇÖ¸ÔÚ×ÓÀàÖÐÉùÃ÷Ó븸ÀàͬÃûµÄ·½·¨£¬´Ó¶ø¸²¸ÇÁ˸¸ÀàµÄ·½·¨¡£Öع¹½â¾öÁË×ÓÀàÓ븸ÀàµÄ²îÒìÎÊÌâ¡£
Àý×ÓÈçÏ£º
//ÖØÔØ
class A {
public d (){};
public d (q){};
public d (q,w){};
}
//ÖØд ......
¾Í¶àÏß³ÌÀ´Ëµ£¬ÎÒÃÇ¿ªÊ¼ÉèÏëÖ»ÓÐÁ½¸öỊ̈߳¨>2ʱÊDz»ÊÇËãÊýѧ¹éÄÉ·¨£¿£©ÄÇôÈç¹ûÁ½¸ö¶ÀÁ¢µÄÏ̻߳ᷢÉúʲôÄØ£¿
1¡£µ±Ò»¸öÏ߳̽øÈëmoniter£¨Ò²¾ÍÊÇ˵վÓÃÒ»¸öobject£©£¬ÁíÒ»¸öÏß³ÌÖ»Óеȴý»ò·µ»Ø£¬¶øÎÒÃÇ°Ñ·µ»Ø¾Í³ÆΪһÖÖģʽ£¬ÕâÖÖģʽµÄÓ¢ÎÄÊÇBalking¡£
2¡£ÕâÁ½¸öÏ߳̿ÉÒÔÊÇÓÐÐòµÄÖ´ÐУ¬¶ø²»ÊÇÈÃOSÀ´µ÷¶È£¬ÕâʱΠ......