Lecture 23, CS 302-7 and 8, March 14, 2012
i. Methods
ii. Add(val)
iii. Size()
iv. Add(ix,val)
v. Set(ix,val)
vi. Remove(ix)
i. Given names:
1. ArrayList<String> namesCopy=new ArrayList<String>(names);
i. Use when you know how many values you need to store
ii. Use if you are really concerned about speed
i. Use when you don’t know how many values you need to store.
ii. Note – arraylists, no initializer list syntax (one other disadvantage…)
i. this means that you can still store the primitive values in the array list – it just needs the type of the wrapper class.
ii. Exampl of what it means to be boxed:
Double wrapper=29.95;
double x=wrapper;
i. Example – Random random in Program2
i. Must specify Type Parameter in both cases in method declaration.
public static ArrayList<Integer> methodName(ArrayList<Integer> aList)
{
}