Stingbiulder, Array, ArrayList
Stringbiulder: variable length for string only.
Array: The length of the array is fixed.
ArrayList: variable length.
Construction Method:
ArrayList ();
To add an element:
Public boolean Add (E E): add element
public void Add (int index,e element): Adding elements at the specified index
ArrayList (E): implementation of variable size arrays
To create a collection object:
arraylist<string> array = new arraylist<string> ();
ArrayList the additions and deletions to change:
1. Adding elements
Array.add ("Hello");
Array.add ("World");
Array.add ("Java");
2. Get elements
Public E get (int index): Returns the element at the specified index
Usage Example: Array.get (0)//run result is Hello
3. Set length
public int size (): Returns the number of elements in the collection
usage example; array.size ();//operation result is 3;
4. Deleting an element
A. Public boolean remove (Object o);//delete the specified element and return whether the deletion succeeded
Usage Example: Array.remove ("Hello");//operation result is ture;
B. public E Remove (int index);//delete the element at the specified index and return the deleted element
Usage Example: Array.remove (1);//operation result is world;
5. Modifying elements (replacing elements)
Public E Set (int index, E Element);//Modify the element at the specified index to be another element (that is, replace) and return the modified element
Usage Example: Array.set (1,android);//operation result is world;
Data for container types in Java