java中的forEach

hong2527發表於2008-04-19
import java.util.*;
import java.text.*;

class Test {
  public static void main(String args[]) throws Exception{
    String a[] = {"~`!@#","$%^&*","()-_+","=|{}","[]:;"","',.?/"};
    for(String s:a) {
      System.out.println(s);
    }

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar cal = Calendar.getInstance();

    Date date0 = formatter.parse("2008-02-29 23:58:58");
    cal.setTime(date0);

    cal.add(Calendar.MINUTE, 5);
    Date date1 = cal.getTime();

    cal.add(Calendar.MONTH, 1);
    Date date2 = cal.getTime();
    
    List list0 = new ArrayList();
    
    list0.add(date0);
    list0.add(date1);
    list0.add(date2);
    
    for(Date d:list0){
      System.out.println(formatter.format(d));
    }
  }
}
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8754345/viewspace-1002742/,如需轉載,請註明出處,否則將追究法律責任。

相關文章