Methods in List class
Add (object): Adds an element to the end of the list.add (integer, object): - Insert an element in to the list at the specified index position.
addAll(List): Adds all of these elements in the specified list to the list that calls the method. Both list must be same type.
addAll(set): Add all of the elements in specified set to the list that calls method. The set and the list must of the same type.
Clear(): Removes all elements from a list consequently setting the list’s length is zero.
Clone (): makes a duplicate copy of a list.
Deep clone (Boolean, Boolean, Boolean): makes a duplicate copy of a list of subject records, including the subject records themselves.
Equals(List): compares this list with the specified list and returns true if both list or equal. Otherwise false.
Get(integer): Returns the list elements stored at the specified index.
Gets object type (): return the token of the object type that makes up a list of subject.
Hash code (): return the hash code corresponding to this list and its contents.
IsEmpty (): returns true if the list has zero elements.
Iterator (): returns an instance of an iterator for this list.
Remove (integer): remove the list element stored at the specified index, returning the element that was removed
Set (integer, object): sets the specified value for the element at the given index.
Size (): Returns the numbers of elements in the list.
Sort (): sorts the items in the list in ascending orders.
Ex: List <string> str = new list <string> ();
String s1 = ’Sam’;
String s2 = ‘ram’;
String s3 =’rave’;
Star. add (s1);
Star. add(s2);
Star. Add (1, s3);
List <string> finalist = new list <string> ();
Finalist. add all (star);
String x = star. get (1); // Ravi
No comments:
Post a Comment