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
}
}
Ïà¹ØÎĵµ£º
Ê×ÏÈÈ·¶¨ÓõÄServlet / JSPµÄ°æ±¾¡£
²é¿´web.xmlµÄ¿ªÍ·²¿·Ö£¬Èç¹ûÓÐÒÔÏÂÄÚÈÝ£¬±íʾÊÇServlet 2.4 / JSP 2.0¡£
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.s ......
ArrayList ºÍVectorÊDzÉÓÃÊý×鷽ʽ´æ´¢Êý¾Ý£¬´ËÊý×éÔªËØÊý´óÓÚʵ¼Ê´æ´¢µÄÊý¾ÝÒÔ±ãÔö¼ÓºÍ²åÈëÔªËØ£¬¶¼ÔÊÐíÖ±½ÓÐòºÅË÷ÒýÔªËØ£¬µ«ÊDzåÈëÊý¾ÝÒªÉè¼Æµ½Êý×éÔªËØÒƶ¯µÈÄÚ´æ²Ù×÷£¬ËùÒÔË÷ÒýÊý¾Ý¿ì²åÈëÊý¾ÝÂý£¬VectorÓÉÓÚʹÓÃÁËsynchronized·½·¨£¨Ḭ̈߳²È«£©ËùÒÔÐÔÄÜÉϱÈArrayListÒª²î£¬LinkedListʹÓÃË«ÏòÁ´±íʵÏÖ´æ´¢£¬°´Ðòº ......
1.Ï̴߳´½¨µÄÁ½ÖÖ·½Ê½
1£©À©Õ¹ThreadÀಢÖØдpublic void run()·½·¨
ps£º
¶¨ÒåỊ̈߳º
class myThread extends Thread(){
public void run(){
System.out.println("Ju ......
ÕâÀïÎÒÃÇÔÙÀí½âÁËAJAXºó£¬¿ªÊ¼À´ÓÃʵÀý¸ÐÊÜAJAXµÄÁ¦Á¿¡£
½ñÌìÎÒ×îºóҪʵÏÖµÄЧ¹û£¬µ±Êó±ê·Åµ½Í¼Æ¬ÉÏʱ»á¸ù¾Ý£¬»á°ÑÊý¾Ý¿â¿âÀïµÄÊý¾Ý¶Á³ö£¬Í¨¹ýÏÔʾ¿òÏÔʾ³öÀ´¡£Õâ¸öÔںܶàÍøÉÏÉ̵궼ÓÐÓõ½ÕâÀïЧ¹û£¬ÎÒÃÇÕâÀïÓÃAJAXÀ´ÊµÏÖÕâ¸öЧ¹û¡£Õâ¸öʵÀýÀï½áºÏÁËMySql¡¢Servlet»¹ÓÐJs£¬ÀíÂÛÐÔºÜÉÙ£¬µ«Í¨¹ýʵ¼ùÀ´¸ÐÊÜÀíÂÛ֪ʶ¡£
......
package javatest1014;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class ReadExcel{
public static void main(String[] args){
jxl.Workbook workbook=getWorkBook();
......