SlideShare a Scribd company logo
The List Interface
 Method: void add(int index, Object o)
 Inserts specified element at specified position
Example:
list.add(4, a); //adds element a at position 4
The List Interface
 Method: boolean add(Object o)
 Adds specified element to the end of the list
Example:
list.add(a); //adds element a at the end of the list
The List Interface
 Method: boolean contains(Object 0)
 Returns true if the specified element is in the list
Example:
list.add(a);
list.contains(a); //returns true
////////////////////////////////////////////////////////////
list.add(b);
list.contains(a); //returns false
The List Interface
 Method: Object get(int index)
 Returns the element at the specified position
Example:
list.add(a);
list.add(b);
list.get(1); //returns b
The List Interface
 Method: int indexOf(object o);
 Returns the index of the specified element or else -1
Example:
list.add(a);
list.add(b);
list.add(c);
list.indexOf(c); //returns 2
The List Interface
 Method: int lastIndexOf(object o);
 Returns the last index of the specified element or
else -1
Example:
list.add(a);
list.add(b);
list.add(a);
list.indexOf(a); //returns 2
The List Interface
 Method: Object remove(int index)
 Removes the element at the specified index
Example:
list.add(a);
list.add(b);
list.add(c);
list.remove(1); //removes element a
The List Interface
 Method: boolean remove(Object o)
 Removes the first occurrence of the specified element
Example:
list.add(a);
list.add(b);
list.add(a);
list.remove(a); //removes element a at position 0
The List Interface
 Method: object set(int index, Object element)
 Replaces the element at the specified position and
returns the old element
Example:
list.add(a);
list.set(0, b); //replaces element a with b and
returns element a
The List Interface
 Method: boolean isEmpty()
 Returns true if the method is empty
Example
list.isEmpty(); //retruns true
////////////////////////////////////////////////////////////
list.add(a);
list.isEmpty(); //returns false
The List Interface
 Method: int size()
 Returns the number of elements in the list
Example:
list.add(a);
list.add(b);
list.add(c);
list.size(); //Returns 3
The List Interface
 Method: boolean addAll(Collection c)
 Appends all the elements in the specified collection to
the end of the list
Example:
list2.add(a);
list2.add(b);
list2.add(c);
list.addAll(list); //adds all elements in list2 to
list
The List Interface
 Method: boolean addAll(int index, Collection c)
 Appends all the elements in the specified collection to
the specified position
Example:
list2.add(a);
list2.add(b);
list.add(a);
list.addAll(0,list); //adds all elements in list2 to
list before element a
The List Interface
 Method: void clear()
 Removes all elements from the list
Example:
list.add(a);
list.add(b);
list.clear(); //removes elements a and b
The List Interface
 Methods: boolean conatainsAll(Collection c)
 Returns true if the list contains all the element in the
collection
Example:
list2.add(a);
list2.add(b);
list.add(a);
list.add(b);
list2.containAll(list); //Returns true
The List Interface
 Method: equals(Object o)
 Compares the specific object with the list for equality
 Example
list.add(a);
list2.add(a);
list.equals(list2); //Returns true
///////////////////////////////////////////////////////////////////////////////
list.add(a);
list2.add(b);
list.equals(list2); //Returns false
The List Interface
 Method: Iterator iterator()
 Returns an iterator over the elements in the list in
proper sequence
 Example
Iterator iter = list.iterator(); //Creates an
iterator for list
The List Interface
 Method: ListIterator listIterator()
 Returns a list iterator over the elements in the list in
proper sequence
Example
ListIterator iter = list.listIterator(); //Creates a
list iterator
The List Interface
 Method: ListIterator listIterator(int index)
 Returns a list iterator over the elements in the list in
proper sequence, starting at the indicated position
Example
ListIterator iter = list.listIterator(2); //Creates
a list iterator starting at 2
The List Interface
 Method: boolean removeAll(collection c)
 Removes all of the elements specified from the list
Example
list2.add(a);
list2.add(b);
list2.add(c);
list.add(a);
list.add(b);
list2.removeAll(list); //Removes elements a and
b
The List Interface
 Method: boolean retainAll(collection c)
 Retains only the elements specified in the list
Example
list2.add(a);
list2.add(b);
list2.add(c);
list.add(a);
list2.retainAll(list); //Removes elements b and c
and keeps a
The List Interface
 Method: List subList(int fromIndex, int toIndex)
 Returns a view of the portion of the list between the
specified indexes
Example
list.add(a);
list.add(b);
list.add(c);
list.add(d);
list.subList(1,3); //returns a view of elements
b,c,d
The List Interface
 Method: Object[] toArray()
 Returns an array containg all of the elements in the
list
Example:
list.add(1);
list.add(2);
list.add(3);
int[] array = list.toArray(); //Creates an array
conating all of lists elements: 1, 2, and 3
The List Interface
 Method: Object[] toArray(Object a)
 Returns an array containg all of the elements in the
list, witht the runtime/ size of the array according to
the object
Example:
list.add(1);
list.add(2);
list.add(3);
int[] array = list.toArray(list); //Creats an array
conating all of lists elements: 1, 2, and 3 with size of list
Iterator Interface
 Method: boolean hasNext()
 Returns true if there are any items in the next position
Example:
While(iter.hasNext()) //Checks if there is a next
position
iter.next();
Iterator Interface
 Method: Object next()
 Returns the next item and moves to the next position
if hasNext is true
Example:
While(iter.hasNext())
iter.next(); //moves the position of the
array to the next spot
Iterator Interface
 Method: void remove()
 Removes item returned by the most recent call of next
Example:
While(iter.hasNext())
iter.next();
iter.remove(); //clears the list
Iterator Interface
 Method: boolean hasPrevious()
 Returns true if there are any items in the previous
position
Example:
While(iter.hasPrevious()) //Checks if there is a
previous position
iter.previous();
Iterator Interface
 Method: Object previous()
 Returns the previous item and moves to the position
before the current location if hasPrevious is true
Example:
While(iter.hasPrevious())
iter.previous(); //moves the position of
the array to the previous spot
Iterator Interface
 Method: Object nextIndex()
 Returns the value of the next index or -1 if none
Example:
list.add(a);
list.add(b);
ListIterator iter = list.listIterator();
iter.nextIndex(); //returns b
/////////////////////////////////////////////////////////////////
list.add(a);
ListIterator iter = list.listIterator();
iter.nextIndex(); //returns -1
Iterator Interface
 Method: Object previousIndex()
 Returns the value of the previous index or -1 if none
Example:
list.add(a);
ListIterator iter = list.listIterator();
iter.previousIndex(); //returns -1
/////////////////////////////////////////////////////////////////
list.add(a);
list.add(b);
iter.next();
ListIterator iter = list.listIterator();
iter.previousIndex(); //returns a
Iterator Interface
 Method: void add(Object 0)
 Inserts an object o at the current pposition
Example:
list.add(a);
list.add(b);
ListIterator iter = list.listIterator();
iter.add(z); // list looks like (z,a,b)
Iterator Interface
 Method: void set(Object o)
 Replaces the last item returned by next or previous
Example:
list.add(a);
list.add(b);
ListIterator iter = list.listIterator();
iter.next();
iter.set(z); //List looks like (a,z)

More Related Content

What's hot

Bubble sorting lab manual
Bubble sorting lab manualBubble sorting lab manual
Bubble sorting lab manual
maamir farooq
 
Lists
Lists Lists
Lists
abdullah619
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - Lists
Yi-Lung Tsai
 
Engineering lecture ppt by venay magen
Engineering lecture ppt by venay magenEngineering lecture ppt by venay magen
Engineering lecture ppt by venay magen
venaymagen19
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
Adam Mukharil Bachtiar
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
Mandeep Singh
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
DurgaDeviCbit
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
Position
PositionPosition
Position
mussawir20
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 

What's hot (12)

Bubble sorting lab manual
Bubble sorting lab manualBubble sorting lab manual
Bubble sorting lab manual
 
Lists
Lists Lists
Lists
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - Lists
 
Engineering lecture ppt by venay magen
Engineering lecture ppt by venay magenEngineering lecture ppt by venay magen
Engineering lecture ppt by venay magen
 
Vector list nd sequence
Vector list nd sequenceVector list nd sequence
Vector list nd sequence
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
Position
PositionPosition
Position
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 

Viewers also liked

Vivametrica Media Coverage_2014
Vivametrica Media Coverage_2014Vivametrica Media Coverage_2014
Vivametrica Media Coverage_2014
Richard Hu
 
AAR - Papal Visit 2015
AAR - Papal Visit 2015AAR - Papal Visit 2015
AAR - Papal Visit 2015Derrick Stokes
 
Zintegrowane systemy zarządzania lech 11
Zintegrowane systemy zarządzania lech 11Zintegrowane systemy zarządzania lech 11
Zintegrowane systemy zarządzania lech 11Wypożyczalnia Żon
 
Performance Knowledge-Based Official Development Assistance Framework
Performance Knowledge-Based Official Development Assistance FrameworkPerformance Knowledge-Based Official Development Assistance Framework
Performance Knowledge-Based Official Development Assistance FrameworkKishor Pradhan, MA, DMC, CKM
 
Reference materials (3)
Reference materials (3)Reference materials (3)
Reference materials (3)amccullar
 
Using the I in BIM for Interiors - CSRW2013
Using the I in BIM for Interiors - CSRW2013Using the I in BIM for Interiors - CSRW2013
Using the I in BIM for Interiors - CSRW2013Kelli Lubeley
 
Confidencias reales
Confidencias realesConfidencias reales
Confidencias reales159aldebaran
 
nama ella azhari, nim: 140601009
nama ella azhari, nim: 140601009nama ella azhari, nim: 140601009
nama ella azhari, nim: 140601009
ellaazh
 
Furoshiki
FuroshikiFuroshiki
Glossary of Pumping terms + Pumps Industry Terminology
Glossary of Pumping terms + Pumps Industry TerminologyGlossary of Pumping terms + Pumps Industry Terminology
Glossary of Pumping terms + Pumps Industry Terminology
March Pump
 
Question 4 - How did you use media technologies in the construction and resea...
Question 4 - How did you use media technologies in the construction and resea...Question 4 - How did you use media technologies in the construction and resea...
Question 4 - How did you use media technologies in the construction and resea...
sallychin98
 
Media Gambar Sholat Jum'at
Media Gambar Sholat Jum'atMedia Gambar Sholat Jum'at
Media Gambar Sholat Jum'atnoviantidyahayu
 
Resort-SS 16 MGF Print Trends-compressed
Resort-SS 16 MGF Print Trends-compressedResort-SS 16 MGF Print Trends-compressed
Resort-SS 16 MGF Print Trends-compressedHailey Steed
 
2001_No1_Thinking_peace_making_peace
2001_No1_Thinking_peace_making_peace2001_No1_Thinking_peace_making_peace
2001_No1_Thinking_peace_making_peaceJacqueline Siapno
 
How to use the Company Connecting Search
How to use the Company Connecting SearchHow to use the Company Connecting Search
How to use the Company Connecting Searchjanice grant-shaw
 

Viewers also liked (18)

Vivametrica Media Coverage_2014
Vivametrica Media Coverage_2014Vivametrica Media Coverage_2014
Vivametrica Media Coverage_2014
 
AAR - Papal Visit 2015
AAR - Papal Visit 2015AAR - Papal Visit 2015
AAR - Papal Visit 2015
 
Zintegrowane systemy zarządzania lech 11
Zintegrowane systemy zarządzania lech 11Zintegrowane systemy zarządzania lech 11
Zintegrowane systemy zarządzania lech 11
 
Performance Knowledge-Based Official Development Assistance Framework
Performance Knowledge-Based Official Development Assistance FrameworkPerformance Knowledge-Based Official Development Assistance Framework
Performance Knowledge-Based Official Development Assistance Framework
 
Reference materials (3)
Reference materials (3)Reference materials (3)
Reference materials (3)
 
Using the I in BIM for Interiors - CSRW2013
Using the I in BIM for Interiors - CSRW2013Using the I in BIM for Interiors - CSRW2013
Using the I in BIM for Interiors - CSRW2013
 
Confidencias reales
Confidencias realesConfidencias reales
Confidencias reales
 
MSFP_C&KMS-FINAL_DRAFT_01.12.2015
MSFP_C&KMS-FINAL_DRAFT_01.12.2015MSFP_C&KMS-FINAL_DRAFT_01.12.2015
MSFP_C&KMS-FINAL_DRAFT_01.12.2015
 
Moral dev 1 (1)
Moral dev 1 (1)Moral dev 1 (1)
Moral dev 1 (1)
 
CVnewshortest
CVnewshortestCVnewshortest
CVnewshortest
 
nama ella azhari, nim: 140601009
nama ella azhari, nim: 140601009nama ella azhari, nim: 140601009
nama ella azhari, nim: 140601009
 
Furoshiki
FuroshikiFuroshiki
Furoshiki
 
Glossary of Pumping terms + Pumps Industry Terminology
Glossary of Pumping terms + Pumps Industry TerminologyGlossary of Pumping terms + Pumps Industry Terminology
Glossary of Pumping terms + Pumps Industry Terminology
 
Question 4 - How did you use media technologies in the construction and resea...
Question 4 - How did you use media technologies in the construction and resea...Question 4 - How did you use media technologies in the construction and resea...
Question 4 - How did you use media technologies in the construction and resea...
 
Media Gambar Sholat Jum'at
Media Gambar Sholat Jum'atMedia Gambar Sholat Jum'at
Media Gambar Sholat Jum'at
 
Resort-SS 16 MGF Print Trends-compressed
Resort-SS 16 MGF Print Trends-compressedResort-SS 16 MGF Print Trends-compressed
Resort-SS 16 MGF Print Trends-compressed
 
2001_No1_Thinking_peace_making_peace
2001_No1_Thinking_peace_making_peace2001_No1_Thinking_peace_making_peace
2001_No1_Thinking_peace_making_peace
 
How to use the Company Connecting Search
How to use the Company Connecting SearchHow to use the Company Connecting Search
How to use the Company Connecting Search
 

Similar to Java collections

Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
xlynettalampleyxc
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
malavshah9013
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
fashiongallery1
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docx
SHIVA101531
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
rishabjain5053
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
maheshkumar12354
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Augstore
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 
STAGE 2 The Methods 65 points Implement all the methods t.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdfSTAGE 2 The Methods 65 points Implement all the methods t.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdf
babitasingh698417
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
ManojKandhasamy1
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
Conint29
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdf
syedabdul78662
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
Komlin1
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
HUST
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
HUST
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
cgraciela1
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdf
ezonesolutions
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructuresmartha leon
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
VictorzH8Bondx
 
List in java
List in javaList in java
List in java
nitin kumar
 

Similar to Java collections (20)

Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docx
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 
STAGE 2 The Methods 65 points Implement all the methods t.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdfSTAGE 2 The Methods 65 points Implement all the methods t.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdf
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdf
 
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 The MyLinkedList class used in Listing 24.6 is a one-way directional .docx The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
The MyLinkedList class used in Listing 24.6 is a one-way directional .docx
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
 
Csphtp1 23
Csphtp1 23Csphtp1 23
Csphtp1 23
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdf
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructures
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
 
List in java
List in javaList in java
List in java
 

Recently uploaded

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 

Java collections

  • 1.
  • 2. The List Interface  Method: void add(int index, Object o)  Inserts specified element at specified position Example: list.add(4, a); //adds element a at position 4
  • 3. The List Interface  Method: boolean add(Object o)  Adds specified element to the end of the list Example: list.add(a); //adds element a at the end of the list
  • 4. The List Interface  Method: boolean contains(Object 0)  Returns true if the specified element is in the list Example: list.add(a); list.contains(a); //returns true //////////////////////////////////////////////////////////// list.add(b); list.contains(a); //returns false
  • 5. The List Interface  Method: Object get(int index)  Returns the element at the specified position Example: list.add(a); list.add(b); list.get(1); //returns b
  • 6. The List Interface  Method: int indexOf(object o);  Returns the index of the specified element or else -1 Example: list.add(a); list.add(b); list.add(c); list.indexOf(c); //returns 2
  • 7. The List Interface  Method: int lastIndexOf(object o);  Returns the last index of the specified element or else -1 Example: list.add(a); list.add(b); list.add(a); list.indexOf(a); //returns 2
  • 8. The List Interface  Method: Object remove(int index)  Removes the element at the specified index Example: list.add(a); list.add(b); list.add(c); list.remove(1); //removes element a
  • 9. The List Interface  Method: boolean remove(Object o)  Removes the first occurrence of the specified element Example: list.add(a); list.add(b); list.add(a); list.remove(a); //removes element a at position 0
  • 10. The List Interface  Method: object set(int index, Object element)  Replaces the element at the specified position and returns the old element Example: list.add(a); list.set(0, b); //replaces element a with b and returns element a
  • 11. The List Interface  Method: boolean isEmpty()  Returns true if the method is empty Example list.isEmpty(); //retruns true //////////////////////////////////////////////////////////// list.add(a); list.isEmpty(); //returns false
  • 12. The List Interface  Method: int size()  Returns the number of elements in the list Example: list.add(a); list.add(b); list.add(c); list.size(); //Returns 3
  • 13. The List Interface  Method: boolean addAll(Collection c)  Appends all the elements in the specified collection to the end of the list Example: list2.add(a); list2.add(b); list2.add(c); list.addAll(list); //adds all elements in list2 to list
  • 14. The List Interface  Method: boolean addAll(int index, Collection c)  Appends all the elements in the specified collection to the specified position Example: list2.add(a); list2.add(b); list.add(a); list.addAll(0,list); //adds all elements in list2 to list before element a
  • 15. The List Interface  Method: void clear()  Removes all elements from the list Example: list.add(a); list.add(b); list.clear(); //removes elements a and b
  • 16. The List Interface  Methods: boolean conatainsAll(Collection c)  Returns true if the list contains all the element in the collection Example: list2.add(a); list2.add(b); list.add(a); list.add(b); list2.containAll(list); //Returns true
  • 17. The List Interface  Method: equals(Object o)  Compares the specific object with the list for equality  Example list.add(a); list2.add(a); list.equals(list2); //Returns true /////////////////////////////////////////////////////////////////////////////// list.add(a); list2.add(b); list.equals(list2); //Returns false
  • 18. The List Interface  Method: Iterator iterator()  Returns an iterator over the elements in the list in proper sequence  Example Iterator iter = list.iterator(); //Creates an iterator for list
  • 19. The List Interface  Method: ListIterator listIterator()  Returns a list iterator over the elements in the list in proper sequence Example ListIterator iter = list.listIterator(); //Creates a list iterator
  • 20. The List Interface  Method: ListIterator listIterator(int index)  Returns a list iterator over the elements in the list in proper sequence, starting at the indicated position Example ListIterator iter = list.listIterator(2); //Creates a list iterator starting at 2
  • 21. The List Interface  Method: boolean removeAll(collection c)  Removes all of the elements specified from the list Example list2.add(a); list2.add(b); list2.add(c); list.add(a); list.add(b); list2.removeAll(list); //Removes elements a and b
  • 22. The List Interface  Method: boolean retainAll(collection c)  Retains only the elements specified in the list Example list2.add(a); list2.add(b); list2.add(c); list.add(a); list2.retainAll(list); //Removes elements b and c and keeps a
  • 23. The List Interface  Method: List subList(int fromIndex, int toIndex)  Returns a view of the portion of the list between the specified indexes Example list.add(a); list.add(b); list.add(c); list.add(d); list.subList(1,3); //returns a view of elements b,c,d
  • 24. The List Interface  Method: Object[] toArray()  Returns an array containg all of the elements in the list Example: list.add(1); list.add(2); list.add(3); int[] array = list.toArray(); //Creates an array conating all of lists elements: 1, 2, and 3
  • 25. The List Interface  Method: Object[] toArray(Object a)  Returns an array containg all of the elements in the list, witht the runtime/ size of the array according to the object Example: list.add(1); list.add(2); list.add(3); int[] array = list.toArray(list); //Creats an array conating all of lists elements: 1, 2, and 3 with size of list
  • 26. Iterator Interface  Method: boolean hasNext()  Returns true if there are any items in the next position Example: While(iter.hasNext()) //Checks if there is a next position iter.next();
  • 27. Iterator Interface  Method: Object next()  Returns the next item and moves to the next position if hasNext is true Example: While(iter.hasNext()) iter.next(); //moves the position of the array to the next spot
  • 28. Iterator Interface  Method: void remove()  Removes item returned by the most recent call of next Example: While(iter.hasNext()) iter.next(); iter.remove(); //clears the list
  • 29. Iterator Interface  Method: boolean hasPrevious()  Returns true if there are any items in the previous position Example: While(iter.hasPrevious()) //Checks if there is a previous position iter.previous();
  • 30. Iterator Interface  Method: Object previous()  Returns the previous item and moves to the position before the current location if hasPrevious is true Example: While(iter.hasPrevious()) iter.previous(); //moves the position of the array to the previous spot
  • 31. Iterator Interface  Method: Object nextIndex()  Returns the value of the next index or -1 if none Example: list.add(a); list.add(b); ListIterator iter = list.listIterator(); iter.nextIndex(); //returns b ///////////////////////////////////////////////////////////////// list.add(a); ListIterator iter = list.listIterator(); iter.nextIndex(); //returns -1
  • 32. Iterator Interface  Method: Object previousIndex()  Returns the value of the previous index or -1 if none Example: list.add(a); ListIterator iter = list.listIterator(); iter.previousIndex(); //returns -1 ///////////////////////////////////////////////////////////////// list.add(a); list.add(b); iter.next(); ListIterator iter = list.listIterator(); iter.previousIndex(); //returns a
  • 33. Iterator Interface  Method: void add(Object 0)  Inserts an object o at the current pposition Example: list.add(a); list.add(b); ListIterator iter = list.listIterator(); iter.add(z); // list looks like (z,a,b)
  • 34. Iterator Interface  Method: void set(Object o)  Replaces the last item returned by next or previous Example: list.add(a); list.add(b); ListIterator iter = list.listIterator(); iter.next(); iter.set(z); //List looks like (a,z)