Effective Java¶ÁÊé±Ê¼Ç
package chape8;
/**
* µÚ8ÕÂ
* µÚ46條£º
* for-eachÑ環優ÏÈÓÚforÑ環
* for(Element e : c)
* {
* dosomthing(e);
* }
* Õâ¸öÊÇjava1.5ÒÔÉϵİ汾µÄforÑ»·µÄÊ×ÏÈ¿¼ÂǵÄд·¨
* ÒÔÏÂÊÇjava1.5ÒÔÇ°µÄ寫·¨
* for (Iterator it = c.iterator();it.hasNext();)
{
it.next();
}
這兩個Ñ環µÄ·½·¨¶¼±Èwhile·½·¨ÒªºÃ£¬45條ÖеÄ複製µÄ錯誤ÔÚÓõÚÒ»種Ñ環¾Í
¿ÉÒÔ±ÜÃ⣻
總Ö®for eachÔÚ簡潔ºÍ預·Àbug·½ÃæÓÐÖø傳統µÄforÑ環無·¨±ÈµÄ優勢£»並ÇÒ沒ÓÐÐÔÄÜ
損ʧ¡£應該¾¹¿ÉÄÜʹÓÃfor-each µ«ÊÇÓÐÏÂ麵Èý種Çé況無·¨Ê¹ÓÃfor each
1.過濾£ºÈç¹û±éÀúÒ»¸ö¼¯ºÏ ²¢É¾³ýÑ¡¶¨µÄÔªËØ ¾ÍÒªÓÃÏÔʾµÄµü´úÆ÷£¬ÕâÑù¿ÉÒÔµ÷ÓÃ
ËûµÄremove·½·¨
2.ת»»£ºÒª±éÀúÁбí»òÕßÊý×é ²¢È¡´úËûµÄ²¿·Ö»òÕßÈ«²¿ÔªËØÖµ ÒªÓõ½Êý×éµÄË÷Òý
3.ƽÐеü´úÒª²¢ÐбéÀú¶à¸ö¼¯ºÏ£»
* @author lee
*
*/
public class Chape46 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Ïà¹ØÎĵµ£º
3.package com.ncs.opts.tools;
import java.util.HashMap;
import java.util.Map;
import com.ncs.opts.common.icp.dao.po.audit.IcpMainHistory;
import com.ncs.opts.common.icp.dao.po.audit.IcpModifyHistory;
import com.ncs.opts.common.icp.dao.po.audit.IcpSiteAccessHistory;
import com.ncs.opts.common.i ......
Java¸ß¼¶££JavaÏß³ÌÔËÐÐÕ»ÐÅÏ¢µÄ»ñÈ¡
·¢²¼Ê±¼ä£º2007.11.14 05:10 À´Ô´£ºÈüµÏÍø¼¼ÊõÉçÇø ×÷Õߣºbaocl
Ò»¡¢ÎÊÌâµÄÒýÈë
ÎÒÃÇÔÚJava³ÌÐòÖÐʹÓÃÈÕÖ¾¹¦ÄÜ£¨JDK Log»òÕßLog4J£©µÄʱºò£¬»á·¢ÏÖLogϵͳ»á×Ô¶¯°ïÎÒÃÇ´òÓ¡³ö·á¸»µÄÐÅÏ¢£¬¸ñʽһ°ãÈçÏ£º
[ÔËÐÐʱ¼ä] [µ ......
Éè¼ÆÒ»¸öCircleÀ࣬ÆäÊôÐÔΪԵ㣨ÀàÐÍΪÀàMyPoint£©ºÍ°ë¾¶£¬²¢Îª´ËÀà±àдÒÔÏÂÈý¸ö·½·¨£º
Ò»¡¢¼ÆËãÔ²µÄÃæ»ýµÄcalArea£¨£©·½·¨£»
¶þ¡¢¼ÆËãÖܳ¤µÄcalLength£¨£©·½·¨£»
Èý¡¢boolean inCircle£¨MyPoint mp£©·½·¨£¬¹¦ÄÜÊDzâÊÔ×÷Ϊ²ÎÊýµÄij¸öµãÊÇ·ñÔÚµ±Ç°¶ÔÏóÔ²ÄÚ£¨Ô²ÄÚ£¬°üÀ¨Ô²ÉÏ·µ»Øtrue£¬ÔÚÔ²Íâ·µ»Øfalse£©¡£
³ÌÐò£º
clas ......
Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader sr=new StreamReader(@"F:\cym\temp\1.txt");
sr.CurrentEncoding //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......
½ñÈÕ¶Áµ½csdnµÄÐÂÎÅ¡¶ÓûΪJava¼¼Êõ´óÅ£ËùÐèµÄ25¸öѧϰҪµã¡·£¬Á˽âÒª×öÒ»¸öJava¼¼Êõ´óÅ£¿É²»ÊÇÒ»°ãÒ»°ãµÄ£¬ÌØÊÕ¼ÔÚ´Ë£ºÒÔ±Þ²ß×Ô¼º²»¶Ïѧϰ£º
1. ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÁ˽âUML£¬ÓÈÆäÊÇclass¡¢object¡¢interactionÒÔ¼°statediagrams¡£
2. ÄãÐèҪѧϰJavaÓïÑÔ ......