10. Difference between Array and ArrayList |
ArrayList can hold primitive variable(the primitive variable will automatically wrap and unwrap when place in/out ArrayList),Array can hold primitive variable |
Arraylist has a lot method(Remove, Add, Contains, IsEmpty, indexof, size, get), Array(can use length variable to get the length of an Array) |
ArrayList can shrink when remove some elem, but Array can't |
Array has to know the size at time it is created, ArrayList not need |
To put an object in an Array, you need assign it to a specific location, ArrayList not need |
ArrayList<String> myList=new ArrayList<String>();
String [] myString=new String[7];
String a=new String("whooo");
myList.add(a);
String a=new String("hiihi");