集合的由来: 目前的学习的语言是一种面向对象语言,面向对象语言对事物的描述通过对象(属性,行为..)体现的,必须给对象进行操作,并且还要针对多个对象进行操作,(使用容器类型的变量):目前学习过的容器:1)数组 2)StringBuffer 1)数组:长度固定,不能满足长度变化的要求 2)StringBuffer:字符串缓冲区,在内存中始终返回的是String类型,也满足一些需求 Java提供一个技术:集合 Collection 层次结构 中的根接口。Collection 表示对象,这些对象也称为 collection 的元素。 一些 collection 允许有重复的元素,而另一些则不允许。一些 collection 是有序的,而另一些则是无序的。 JDK 不提供此接口的任何直接 实现:它提供更具体的子接口(如 Set 和 List)实现。 添加功能: boolean add(Object e):添加单个元素 boolean addAll(Collection c):添加一个集合中的元素 删除功能:r void clear() remove(Object o) removeAll(Collection c):移除一个集合中的元素
判断功能: boolean contains(Object o):一个集合中是否包含指定的元素 boolean containsAll(Collection c):包含一个集合中的元素
boolean isEmpty():判断集合是否为空. 空,就是true

获取功能: int size() :获取元素数的方法 Iterator iterator():迭代器 (遍历集合的特有功能) 转换功能: Object[] toArray() :将集合转换成数组 Collection的高级功能: boolean addAll(Collection c):添加一个集合中的元素 removeAll(Collection c):移除一个集合中的元素
迭代器源码: public interface Iterable{ Iterator<T> iterator(); } //接口 interface Iterator{ boolean hasNext() ; Object next() ; } interface Collection{ } interface List extends Collection{ } class ArrayList implements List{ public Iterator<E> iterator() { return new Itr(); //匿名对象:Itr }

  //内部类:Itr
   private class Itr implements Iterator<E> {
   	//判断是否有下一个元素
   	   public boolean hasNext() {
        return cursor != size;
    	}
    	
    	//获取下一个迭代的元素
    	public E next() {
   		}
    	
   }

} Date:表示日期格式,精确到毫秒

Date() 比较常用的 :获取当前的系统时间:以Date格式来表现的 public Date(long date)分配 Date 对象并初始化此对象,以表示自从标准基准时间(称为“历元(epoch)” 即 1970 年 1 月 1 日 00:00:00 GMT)以来的指定毫秒数。 Date---->long public long getTime()

public void setTime(long time) :很少用 (重点) Date---->String之间如何转换 日期格式 日期文本格式

本身两者之间的转换用到:DateFormat这个类:他是一个抽象类,不能实例化!用它的子类:SimpleDateFormat Date----String 格式化 String format(Date date) String--Date 解析 public Date parse(String source) throws parseEception (编译时期异常)

SimpleDateFormat的构造方法

SimpleDateFormat(String pattern): 参数表示: pattern:当前日期使用哪一种模式:开发者规定xxxx年xx月 xx日 xx时 x分x秒 xxxx-xx-xx

  	年:	y			   yyyy
  	月:M               MM
  	日: d				dd 			yyyy-MM-dd HH:mm:ss

System in:标准输入流 InputStream 字节输入流 out:标准输出流 PrintStream 字节打印流 PrintWriter:字符打印流

gc():public static void gc()  :Java 虚拟机做了一些努力来回收未用对象
			开启垃圾回收器,其实质是是调用了重写Object中的finalize()方法

public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) 从指定源数组中的某个位置开始复制,复制目标数组中的某个位置,指定长度.