Container (collection) classification:
Generics (generic): essentially parametric data types (tell the compiler in advance, it must pass the actual type in calling a generic)
Example: E that is defined in the main function of the actual type passed
class MyCollection<E>{
Object[] objs = new Object[5];
public void Set(E e,int a) {
objs[a] = e;
}
public E Get(int a) {
return (E)(objs[a]);
}
}
Collectio interface methods:
Collection <String> c = new ArrayList<>();
c.size (): the magnitude of the output c
c.isEmpty (): Verify c is empty, return value of true or false
c.add ( "l"): insert objects into l c,
c.contains ( "l"): Verify that contained c l, returns a value of true or false
c.remove ( "l"): removing the object from the l c, (l object still exists, but the address is no longer associated with c)
c.clean (): remove all objects c
The method set between the set:
List<String> list01 = new ArrayList<String>();
List<String> list02 = new ArrayList<String>();
list01.removeAll (list02): remove the object 01 coincides with the 02
list01.addAll (list02): Add all the items in the 02 to 01
list01.retainAll (list02): 01,02 retain only overlapping objects
list01.containsAll (list02): Verify 01 entirely contains 02, returns a value of true or false.
list method:
list.add (1, "ljl"): reload the add method, the object is added at a
list.set (1, "xrw"): an object at 1 Change xrw
list.remove (4): removal of the object 4
Object get1 at: (1) list.get
list.indexOf ( "A"): Returns the index of the location A, or -1 if not
list.lastIndexOf ( "A"): A return to a position in which the index of the last, or -1 if not