| ArrayList ArrayList<String> myList = new
 ArrayList<String>();
 一般数组
 String [] myList = new String[2];
 
 ArrayList
 String a = new String("hello");
 myList.add(a);
 一般数组
 String a = new String ("hello");
 myList[0] = a;
 
 ArrayList
 String b = new String ("haha");
 myList.add(b);
 一般数组
 String b = new String("haha");
 myList[1] = b;
 
 ArrayList
 int theSize = myList.size();
 一般数组
 int theSize = myList.length;
 
 ArrayList
 Object o = myList.get(1);
 一般数组
 String o = myList[1];
 
 ArrayList
 myList.remove(1);
 一般数组
 myList[1] = null;
 
 ArrayList
 boolean isIn = myList.contains|(c);
 一般数组
 boolean isIn = false;
 for(String item : myList)
 {
 if(c.equals(item))
 {
 isIn = ture;
 
 break;
 }
 }
 
 1.一般数组在创建时就必须要确定大小但是对ArrayList来说,你只需要创建出此类
 
 型的对象就行,它不需要指定大小,因为它会在加入或者删除元素时自动调整大小
 new String[2]  //指定大小
 new ArrayList<String>()  //不需要指定大小
 2.存放对象给一般数组时必须指定位置(必须要指定介于0到length小1之间的数字)
 myList[1] = b;        指定索引值
 如果索引值超越了数组的限制,程序会在执行期出现错误
 
 使用ArrayList时,你可以用add(Int,Object)这个形式的方法来指定索引值,或者
 
 使用add(Object)的形式来给他自行管理大小
 3.一般数组使用特殊的语法
 但是ArrayList是个普通对象,所以不会有特殊的语法
 myList[1]        [方括号]是只用在数组上的特殊语法
 4.在Java5.0中的ArrayList是参数化的(parameterized)
 虽然ArrayList不像一般数组有特殊的语法,但是他们在java5.0中有比较特殊的东
 
 西——参数化类型.
 ArrayList<String>  <String>是类型参数.这代表String的集合,就是说
 
 ArrayList<Dog>代表Dog的集合.
 
 在使用ArrayList时,你只是在运用ArrayList类型的对象,因此就跟运用其他的对象一样,可以使用“.”运算符来调用它的方法
 
 在使用一般数组时,可以使用特殊的数组语法来操作,这样的语法只能用在数组上,虽说数组也是对象,但是有自己的规则,我们无法调用它的方法,最多只能存取它的length实例变量.
 
 有不足的希望大家补充下,谢谢了
 |