SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
- B Y
D I M P Y C H U G H ( 1 8 3 3 )
D R I S H T I B H A L L A ( 1 8 3 8 )
COLLECTIONS API
COLLECTION API
 Collection in java is a framework that provides an
architecture to store and manipulate the group of
objects.
 Java Collection Framework is a collection of many
interfaces( Set, List, Queue,Map) and classes (ArrayList,
Vector,LinkedList,PriorityQueue,HashSet,TreeSet,Tree
Map etc).
 All the operations that you perform on a data such as
searching, sorting, insertion, manipulation, deletion etc.
can be performed by Java Collections.
METHODS OF COLLECTION INTERFACE
No. Method Description
1 public boolean add(Object element) is used to insert an element in this
collection.
2 Object get(int index) Returns the element at the specified
position in the collection..
3 public boolean addAll(Collection c) is used to insert the specified collection
elements in the invoking collection.
4 public boolean remove(Object element) is used to delete an element from this
collection.
5 public int size() return the total number of elements in the
collection.
6 public void clear() removes the total no of element from the
collection.
7 public boolean contains(Object element) is used to search an element.
8 public boolean containsAll(Collection c) is used to search the specified collection in
this collection.
9 public Iterator iterator() returns an iterator.
10 public boolean isEmpty() checks if collection is empty.
11 public boolean equals(Object element) matches two collection.
INTERFACES
LIST- List of things
Allows duplicates
QUEUE- Things in FIFO manner
Allows duplicates & null values
SET- Unique Things
Allows null values
MAP – Things with unique key
Allows duplicate values
TRAVERSING TECHNIQUES
1) Using Iterator Interface
Iterator Interface is used to traverse the elements in forward direction
only. It has 2 main functions:
 public boolean hasNext()- It returns true if iterator has more
elements.
 public object next()- It returns the element and moves the cursor
pointer to the next element.
 For Example:
Iterator it=list.iterator();
while(it.hasNext())
{
System.out.println( " Element :" + it.next());
}
2) Using Enumeration Interface
Enumeration provides two methods to enumerate through the
elements.
 public boolean hasMoreElements()- returns true if there
are more elements to enumerate through otherwise it returns
false.
 public object nextElement()- returns the next element in
enumeration.
 For Example:
Enumeration e=v1.elements();
while(e.hasMoreElements())
{
System.out.println(e.nextElement());
}
3) Using ListIterator Inteface
ListIterator Interface is used to traverse the element in backward and
forward direction. It has 4 main functions:
 public boolean hasNext()- Returns true if this list iterator has
more elements when traversing the list in the forward direction
 public Object next()- Returns the next element in the list and
advances the cursor position.
 public boolean hasPrevious()- Returns true if this list iterator
has more elements when traversing the list in the reverse direction.
 public Object previous()- Returns the previous element in the
list and moves the cursor position backwards.
 Example for Traversing backwards
ListIterator itr=al.listIterator();
while(itr.hasPrevious())
{
System.out.println(itr.previous());
}
ARRAYLIST
 ArrayList is an inbuilt class that implements the List
interface.
 It uses dynamic array for storing the elements.
 It maintains insertion order.
 It takes NULL, TRUE, FALSE as elements of the list.
 In ArrayList, manipulation is slow because a lot of shifting
needs to be occurred if any element is removed from the
array list.
 Elements of ArrayList can be traversed using Iterator .
 Creating a new ArrayList
ArrayList al=new ArrayList();
VECTORS
 Vector implements the List Interface.
 It is similar to ArrayList as it also contains growable
array data structure, but with two differences:
I. Vector is synchronized- This means if one thread is
working on a Vector, no other thread can get a hold of
it. Unlike ArrayList, only one thread can perform an
operation on vector at a time.
II. Vector give poor performance- Operations on
elements gives poor performance as they are thread-
safe, the thread which works on Vector gets a lock on
it which makes other thread wait till the lock is
released.
 It maintains the insertion order.
 Allows duplicate elements in the list.
 Vector can be traversed by Enumerator or Iterator.
 Creating a new Vector
Vector v1=new Vector();
Additional Functions of Vector class
1) int capacity()- Returns the current capacity of this vector.
2) int indexOf(Object elem)- Searches for the first occurrence of the
given argument, testing for equality using the equals methodand -1 if the
vector does not contain this element.
LINKED LISTS
 LinkedList implements the List interface.
 Java LinkedList class uses doubly linked list to store the
elements.
 It can contain duplicate elements.
 Maintains insertion order.
 It is non synchronized.
 Java LinkedList class can be used as list, stack or queue.
 Linkedlist have same functions as that of collection interface.
 Creating a new LinkedList
LinkedList list=new LinkedList();
PRIORITY QUEUE
 PriorityQueue implements the Queue interface.
 Elements are added in any random order.
 Allows duplicate elements in the queue.
 It does not permit null elements.
 Head of the Queue is the least item in the order.
 A PriorityQueue is traversed using Iterator.
 Creating a new PriorityQueue
PriorityQueue p1=new PriorityQueue();
Additional Functions of PriorityQueue
1) Object peek()- This method retrieves, but does not remove, the
head of this queue, or returns null if this queue is empty.
2) Object poll()- This method retrieves and removes the head of
this queue, or returns null if this queue is empty.
HASHSET
 HashSet implements the Set interface. It uses hashtable to store
the elements.
 No insertion order is maintained.
 It permits null element.
 HashSet is traversed by Iterator.
 It contains unique elements only. But in case new objects are
formed i.e. memory locations are different , the hashset cannot
avoid duplicacy.
 Hashset have same functions as that of collection interface.
 Creating a new HashSet
HashSet set=new HashSet();
LINKED-HASHSET
 LinkedHashSet maintains a linked list of the entries in
the set, in the order in which they were inserted.
 It contains unique elements only like HashSet. It
extends HashSet class and implements Set interface.
 It is traversed by Iterator.
 The functions of LinkedHashset are same as Hashset.
 Creating a new LinkedHashSet
LinkedHashSet set=new LinkedHashSet();
TREESET
 It contains unique elements only like HashSet and implements Set interface .
 Elements are stored in sorted, ascending order.
 Access and retrieval times are quite fast, which makes TreeSet an excellent
choice when storing large amounts of sorted information that must be found
quickly.
 Creating a new TreeSet
TreeSet set=new TreeSet();
 Additional Functions of TreeSet
1) Object first()-Returns the first (lowest) element currently in this sorted set.
2) Object last()-Returns the last (highest) element currently in this sorted set.
3) SortedSet subSet(Object fromElement, Object toElement)-Returns
a view of the portion of this set whose elements range from fromElement,
inclusive, to toElement, exclusive.
HASHMAP
 HashMap maintains key and value pairs and are denoted as
HashMap<Key, Value> .
 It implements the Map interface.
 It can not take duplicate keys but can have duplicate values.
 It allows null key and null values.
 It maintains no order.
 It is mandatory to specify both key and value. Specifying key and
keeping value empty or vice-versa gives compile time error.
 HashMap is traversed by Iterator.
 It is non-synchronised.
 Creating a new HashMap
HashMap map=new HashMap();
 Additional Functions of HashMap
1. Set entrySet()- Returns a collection view of the mappings
contained in this map.
2. Object put(Object key, Object value)- Associates the
specified value with the specified key in this map.
3. Object remove(Object key)- Removes the mapping for
this key from this map if present.
4. boolean containsKey(Object key)- Returns true if this
map contains a mapping for the specified key.
LINKEDHASHMAP
 LinkedHashMap maintains a linked list of the entries
in the map, in the order in which they were inserted.
 It extends HashMap class and implements the Map
interface .
 It is same as HashMap instead maintains insertion
order of keys.
 It is traversed by Iterator.
 LinkedHashMap has same functions as that of
HashMap.
 Creating a new LinkedHashMap
LinkedHashMap map=new LinkedHashMap();
TREEMAP
 TreeMap class implements the Map interface by using a
tree.
 It can not take duplicate keys but can have duplicate values.
 It cannot have null key but can have multiple null values.
 A TreeMap provides an efficient means of storing key/value
pairs in sorted order, and allows rapid retrieval.
 TreeMap has same functions as that of HashMap.
 Creating a new TreeMap
TreeMap map=new TreeMap();
HASHTABLE
 HashTable implements the Map interface .
 Like HashMap, Hashtable stores key-value pairs. When
using a Hashtable, we specify an object that is used as a
key, and the value that we want linked to that key. The key
is then hashed, and the resulting hash code is used as the
index at which the value is stored within the table.
 It contains only unique elements.
 Any non-null object can be used as a key or as a value.
 Unlike HashMap, It is synchronized.It is thread-safe and
can be shared with many threads.
 Creating a new HashTable
HashTable map=new HashTable();
THANKYOU!!

Weitere ähnliche Inhalte

Was ist angesagt?

Java collections concept
Java collections conceptJava collections concept
Java collections conceptkumar gaurav
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection frameworkankitgarg_er
 
Java Lambda Expressions.pptx
Java Lambda Expressions.pptxJava Lambda Expressions.pptx
Java Lambda Expressions.pptxSameerAhmed593310
 
java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets Hitesh-Java
 
Collections in Java
Collections in JavaCollections in Java
Collections in JavaKhasim Cise
 
Java Collections
Java CollectionsJava Collections
Java Collectionsparag
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8Knoldus Inc.
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Java Serialization
Java SerializationJava Serialization
Java Serializationimypraz
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
 

Was ist angesagt? (20)

Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 
Java collections
Java collectionsJava collections
Java collections
 
Java Lambda Expressions.pptx
Java Lambda Expressions.pptxJava Lambda Expressions.pptx
Java Lambda Expressions.pptx
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
 
Java Collections
Java CollectionsJava Collections
Java Collections
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 

Ähnlich wie Collections Api - Java

11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.pptNaitikChatterjee
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionssuseredfbe9
 
LJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptxLJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptxRaneez2
 
Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questionsyearninginjava
 
Array list (java platform se 8 )
Array list (java platform se 8 )Array list (java platform se 8 )
Array list (java platform se 8 )charan kumar
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfadvancethchnologies
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfgiriraj65
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfadityacomputers001
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections frameworkRavi Chythanya
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptxSoniaKapoor56
 

Ähnlich wie Collections Api - Java (20)

Java.util
Java.utilJava.util
Java.util
 
Collections framework
Collections frameworkCollections framework
Collections framework
 
22.collections(1)
22.collections(1)22.collections(1)
22.collections(1)
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
LJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptxLJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptx
 
Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questions
 
16 containers
16   containers16   containers
16 containers
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
Array list (java platform se 8 )
Array list (java platform se 8 )Array list (java platform se 8 )
Array list (java platform se 8 )
 
ArrayList.docx
ArrayList.docxArrayList.docx
ArrayList.docx
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 
Linked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdfLinked List Objective The purpose of this exercise is to cr.pdf
Linked List Objective The purpose of this exercise is to cr.pdf
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections framework
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptx
 

Mehr von Drishti Bhalla

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures Drishti Bhalla
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & NetworkingDrishti Bhalla
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - MathematicsDrishti Bhalla
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - MathematicsDrishti Bhalla
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsDrishti Bhalla
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringDrishti Bhalla
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRMDrishti Bhalla
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instructionDrishti Bhalla
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4Drishti Bhalla
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System ThreatsDrishti Bhalla
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software EngineeringDrishti Bhalla
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationDrishti Bhalla
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management SystemDrishti Bhalla
 

Mehr von Drishti Bhalla (16)

Propositions - Discrete Structures
Propositions - Discrete Structures Propositions - Discrete Structures
Propositions - Discrete Structures
 
Physical Layer Numericals - Data Communication & Networking
Physical Layer  Numericals - Data Communication & NetworkingPhysical Layer  Numericals - Data Communication & Networking
Physical Layer Numericals - Data Communication & Networking
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
 
Matrices - Mathematics
Matrices - MathematicsMatrices - Mathematics
Matrices - Mathematics
 
Holy Rivers - Hindi
Holy Rivers - HindiHoly Rivers - Hindi
Holy Rivers - Hindi
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
 
Performance Management and Feedback - SHRM
Performance Management and Feedback - SHRMPerformance Management and Feedback - SHRM
Performance Management and Feedback - SHRM
 
Computer System Architecture - BUN instruction
Computer System Architecture - BUN instructionComputer System Architecture - BUN instruction
Computer System Architecture - BUN instruction
 
King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4King of acids -Sulphuric Acid H2SO4
King of acids -Sulphuric Acid H2SO4
 
Information Technology - System Threats
Information Technology - System ThreatsInformation Technology - System Threats
Information Technology - System Threats
 
Software Metrics - Software Engineering
Software Metrics - Software EngineeringSoftware Metrics - Software Engineering
Software Metrics - Software Engineering
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
CNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of ComputationCNF & Leftmost Derivation - Theory of Computation
CNF & Leftmost Derivation - Theory of Computation
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 

Kürzlich hochgeladen

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Collections Api - Java

  • 1. - B Y D I M P Y C H U G H ( 1 8 3 3 ) D R I S H T I B H A L L A ( 1 8 3 8 ) COLLECTIONS API
  • 2. COLLECTION API  Collection in java is a framework that provides an architecture to store and manipulate the group of objects.  Java Collection Framework is a collection of many interfaces( Set, List, Queue,Map) and classes (ArrayList, Vector,LinkedList,PriorityQueue,HashSet,TreeSet,Tree Map etc).  All the operations that you perform on a data such as searching, sorting, insertion, manipulation, deletion etc. can be performed by Java Collections.
  • 3. METHODS OF COLLECTION INTERFACE No. Method Description 1 public boolean add(Object element) is used to insert an element in this collection. 2 Object get(int index) Returns the element at the specified position in the collection.. 3 public boolean addAll(Collection c) is used to insert the specified collection elements in the invoking collection. 4 public boolean remove(Object element) is used to delete an element from this collection. 5 public int size() return the total number of elements in the collection. 6 public void clear() removes the total no of element from the collection. 7 public boolean contains(Object element) is used to search an element. 8 public boolean containsAll(Collection c) is used to search the specified collection in this collection. 9 public Iterator iterator() returns an iterator. 10 public boolean isEmpty() checks if collection is empty. 11 public boolean equals(Object element) matches two collection.
  • 4. INTERFACES LIST- List of things Allows duplicates QUEUE- Things in FIFO manner Allows duplicates & null values SET- Unique Things Allows null values MAP – Things with unique key Allows duplicate values
  • 5. TRAVERSING TECHNIQUES 1) Using Iterator Interface Iterator Interface is used to traverse the elements in forward direction only. It has 2 main functions:  public boolean hasNext()- It returns true if iterator has more elements.  public object next()- It returns the element and moves the cursor pointer to the next element.  For Example: Iterator it=list.iterator(); while(it.hasNext()) { System.out.println( " Element :" + it.next()); }
  • 6. 2) Using Enumeration Interface Enumeration provides two methods to enumerate through the elements.  public boolean hasMoreElements()- returns true if there are more elements to enumerate through otherwise it returns false.  public object nextElement()- returns the next element in enumeration.  For Example: Enumeration e=v1.elements(); while(e.hasMoreElements()) { System.out.println(e.nextElement()); }
  • 7. 3) Using ListIterator Inteface ListIterator Interface is used to traverse the element in backward and forward direction. It has 4 main functions:  public boolean hasNext()- Returns true if this list iterator has more elements when traversing the list in the forward direction  public Object next()- Returns the next element in the list and advances the cursor position.  public boolean hasPrevious()- Returns true if this list iterator has more elements when traversing the list in the reverse direction.  public Object previous()- Returns the previous element in the list and moves the cursor position backwards.  Example for Traversing backwards ListIterator itr=al.listIterator(); while(itr.hasPrevious()) { System.out.println(itr.previous()); }
  • 8. ARRAYLIST  ArrayList is an inbuilt class that implements the List interface.  It uses dynamic array for storing the elements.  It maintains insertion order.  It takes NULL, TRUE, FALSE as elements of the list.  In ArrayList, manipulation is slow because a lot of shifting needs to be occurred if any element is removed from the array list.  Elements of ArrayList can be traversed using Iterator .  Creating a new ArrayList ArrayList al=new ArrayList();
  • 9. VECTORS  Vector implements the List Interface.  It is similar to ArrayList as it also contains growable array data structure, but with two differences: I. Vector is synchronized- This means if one thread is working on a Vector, no other thread can get a hold of it. Unlike ArrayList, only one thread can perform an operation on vector at a time. II. Vector give poor performance- Operations on elements gives poor performance as they are thread- safe, the thread which works on Vector gets a lock on it which makes other thread wait till the lock is released.
  • 10.  It maintains the insertion order.  Allows duplicate elements in the list.  Vector can be traversed by Enumerator or Iterator.  Creating a new Vector Vector v1=new Vector(); Additional Functions of Vector class 1) int capacity()- Returns the current capacity of this vector. 2) int indexOf(Object elem)- Searches for the first occurrence of the given argument, testing for equality using the equals methodand -1 if the vector does not contain this element.
  • 11. LINKED LISTS  LinkedList implements the List interface.  Java LinkedList class uses doubly linked list to store the elements.  It can contain duplicate elements.  Maintains insertion order.  It is non synchronized.  Java LinkedList class can be used as list, stack or queue.  Linkedlist have same functions as that of collection interface.  Creating a new LinkedList LinkedList list=new LinkedList();
  • 12. PRIORITY QUEUE  PriorityQueue implements the Queue interface.  Elements are added in any random order.  Allows duplicate elements in the queue.  It does not permit null elements.  Head of the Queue is the least item in the order.  A PriorityQueue is traversed using Iterator.  Creating a new PriorityQueue PriorityQueue p1=new PriorityQueue(); Additional Functions of PriorityQueue 1) Object peek()- This method retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. 2) Object poll()- This method retrieves and removes the head of this queue, or returns null if this queue is empty.
  • 13. HASHSET  HashSet implements the Set interface. It uses hashtable to store the elements.  No insertion order is maintained.  It permits null element.  HashSet is traversed by Iterator.  It contains unique elements only. But in case new objects are formed i.e. memory locations are different , the hashset cannot avoid duplicacy.  Hashset have same functions as that of collection interface.  Creating a new HashSet HashSet set=new HashSet();
  • 14. LINKED-HASHSET  LinkedHashSet maintains a linked list of the entries in the set, in the order in which they were inserted.  It contains unique elements only like HashSet. It extends HashSet class and implements Set interface.  It is traversed by Iterator.  The functions of LinkedHashset are same as Hashset.  Creating a new LinkedHashSet LinkedHashSet set=new LinkedHashSet();
  • 15. TREESET  It contains unique elements only like HashSet and implements Set interface .  Elements are stored in sorted, ascending order.  Access and retrieval times are quite fast, which makes TreeSet an excellent choice when storing large amounts of sorted information that must be found quickly.  Creating a new TreeSet TreeSet set=new TreeSet();  Additional Functions of TreeSet 1) Object first()-Returns the first (lowest) element currently in this sorted set. 2) Object last()-Returns the last (highest) element currently in this sorted set. 3) SortedSet subSet(Object fromElement, Object toElement)-Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
  • 16. HASHMAP  HashMap maintains key and value pairs and are denoted as HashMap<Key, Value> .  It implements the Map interface.  It can not take duplicate keys but can have duplicate values.  It allows null key and null values.  It maintains no order.  It is mandatory to specify both key and value. Specifying key and keeping value empty or vice-versa gives compile time error.  HashMap is traversed by Iterator.  It is non-synchronised.  Creating a new HashMap HashMap map=new HashMap();
  • 17.  Additional Functions of HashMap 1. Set entrySet()- Returns a collection view of the mappings contained in this map. 2. Object put(Object key, Object value)- Associates the specified value with the specified key in this map. 3. Object remove(Object key)- Removes the mapping for this key from this map if present. 4. boolean containsKey(Object key)- Returns true if this map contains a mapping for the specified key.
  • 18. LINKEDHASHMAP  LinkedHashMap maintains a linked list of the entries in the map, in the order in which they were inserted.  It extends HashMap class and implements the Map interface .  It is same as HashMap instead maintains insertion order of keys.  It is traversed by Iterator.  LinkedHashMap has same functions as that of HashMap.  Creating a new LinkedHashMap LinkedHashMap map=new LinkedHashMap();
  • 19. TREEMAP  TreeMap class implements the Map interface by using a tree.  It can not take duplicate keys but can have duplicate values.  It cannot have null key but can have multiple null values.  A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval.  TreeMap has same functions as that of HashMap.  Creating a new TreeMap TreeMap map=new TreeMap();
  • 20. HASHTABLE  HashTable implements the Map interface .  Like HashMap, Hashtable stores key-value pairs. When using a Hashtable, we specify an object that is used as a key, and the value that we want linked to that key. The key is then hashed, and the resulting hash code is used as the index at which the value is stored within the table.  It contains only unique elements.  Any non-null object can be used as a key or as a value.  Unlike HashMap, It is synchronized.It is thread-safe and can be shared with many threads.  Creating a new HashTable HashTable map=new HashTable();