SlideShare a Scribd company logo
javeed
 A Collection is a container that groups similar elements
into an entity.
 Examples would include a list of bank accounts, set of
students, group of telephone numbers.
 The Collections framework in Java offers a unified
approach to store, retrieve and manipulate a group of
data
 Java’s Collection framework has an intuitive approach
when compared to other complex frameworks such as
C++
 Helpful to developers by providing all standard data structures
algorithms to let the developer concentrate more on functionality
rather than the lower level details
 Faster execution: with a range of options available for choice of
implementation. The framework aids in improving the quality and
performance of Java applications.
 Code to interface: Since the collections framework is coded on the
principles of “Code to Interface”, it aids in inter-operability between
APIs that are not directly related.
 Learning Curve: Easy to learn and start using Collections due to the
“Code to Interface” principles.
 The Collection framework forms a suitable
hierarchy:
Collection
Set List Queue
SortedSet
Map
SortedMap
 The core Collections framework is very generic in nature and provides a
standard interface to all operations that can be performed.
 For example the root interface Collection is declared as public interface
Collection <E>
◦ E represents a generic object.
 Collection: This interface is pretty much used in declarations and method
signatures so any type of Collections can be passed around.
 Set: A Collection interface that cannot take any duplicate elements.
 List: An ordered Collection interface that allows duplicate elements and provides
object retrieval based on an integer index.
 Queue: Apart from following the FIFO (First In First Out) principles this
Collection offers variety of implementation.
 Map: Supports Collection of key and value pairs. Design does not allow
duplicate keys.
 Sorted Set: Ordered version of the set interface.
 Sorted Map: Maintains ascending order of keys.
 boolean isEmpty();
 boolean contains (Object element);
 boolean remove (Object element);
 Interface <E> iterator();
 boolean containsAll (Collection <> C);
 boolean addAll (Collection <? extends E> C);
 boolean removeAll (Collection() > C);
c.removeAll (Collections.Singleton(obj);
 boolean retainAll (Collection <?> C);
 void clear();
 Object[ ] toArray();
 <T> T[ ] toArray(T[ ]a);
 Two ways to iterate over Collections:
◦ Iterator
static void loopThrough(Collection col){
for (Iterator <E> iter = col.iterator();iter.hasnext()) {
Object obj=iter.next();
}
}
◦ For-each
static void loopThrough(Collection col){
for (Object obj: col) {
//access object
}
}
 Set Interface: It offers inherited services from the root
Collection interface with the added functionality of
restricting duplicate elements.
 Implementations:
Set
HashSet TreeSet LinkedHashSet
 Adding unique objects to a collection
Collection <String> uniqueString (Collection<String> c)
{
Set<String> uniqueSetStr = new HashSet<String>();
for (String str: c)
{
if(!uniqueStrSet.add(str)){
System.out.println(“Duplicate deleted:”+ str);
}
}
return uniqueStrSet;
 Idioms for using bulk operations on sets:
 Copy a set when doing bulk operations to retain the original set.
 Example:
Set <String> unionSet = new TreeSet<String>(set1);
unionSet.addAll(set2);
HashSet TreeSet Linked HashSet
Storage Type Hash Table Red-Black Tree Hash Table with
a Linked List
Performance Best
performance
Slower than
HashSet
Little costly than
HashSet
Order of
Iteration
No guarantee of
order of
iteration
Order based Orders elements
based on
insertion
 In addition to the core services inherited from the root collection
interface, the list interface offers
◦ Positional access
◦ Search
◦ Customized Iteration
◦ Range-view
 List Implementation
◦ ArrayList offers better performance compared to Linkedlist.
List
Arraylist Vector Linkedlist
 Bulk Operations
◦ listA.addAll(listB); // append elements.
 Positional access and search
◦ Eg: To swap elements in a list.
public static<String> void swap(List<String>strList, int k, int l)
{
String strTmp = strList.get(l);
strList.set(k,strList.get(l));
strList.set(l,strTmp);
}
 Customized Iteration: ListIterator
◦ Offers iteration in both directions, forward and backward
◦ Example:
for(ListIterator<String>
lIter=strList.listIterator(strList.size());lIter.hasPrevious())
{
String str = lIter.previous();
}
 Range-View:
◦ subList(int from, int to) returns a view portion of the
sublist starting from <from> to <to> exclusive.
 sort: Uses mergesort
 shuffle: Randomly shuffles elements
 reverse: Reverses order of elements
 rotate: Rotates list by specified number
 fill: Overwrites every element with specified element.
 copy: Copies source list into destination.
 binarySearch: Performs search usng binary search.
 indexOfSubList: Returns index of first subList found.
 lastIndexOfSubList: Returns index of the last subList found.
 In addition to the inherited core services offered by
Collection, queue offers following methods in two flavors:
Purpose Throw
Exception
Return Special
Value
Insert Inserts an elements
to the queue
add(obj) offer(obj)
Remove Remove head of the
queue and return it.
remove() poll()
Examine Return the head of
the queue
element() peek()
 Basic operations:
◦ Val put (Object key);
◦ Val get (Object key);
◦ Val remove (Object key);
◦ boolean containsKey (Object key);
◦ boolean containsValue (Object value);
◦ int size();
◦ boolean isEmpty();
 Bulk services
◦ Void putAll(Map<? extends Key, ? extends Val> map);
◦ void clear();
 Views
public set<Key> keySet();
public collection<Val> values();
public set<Maps.Entry<Key,Val>> entrySet();
 Examples:
Iteration over a map
for(Map.Entry<?,vtype> elem: map.entrySet())
System.out.print(element.getKey()+”:”+element.getValue());
To find If a map contains another map
If(map1.entrySet().containsAll(Map2.entrySet()))
If two map objects contain same keys
If(map1.keyset().equals(map2.keyset()))
To find out common keys behave two map objects
Set<Ktype> common keys = new Hashset<Ktype>(map1.commonkeys.retainAll(map2.keyset());
Performance Increases
Map
HashMap TreeMap Linkedlist HashTable
 SortedSet stores elements in ascending order as per the natural
ordering or as defined by a comparator provided at instantiation time.
 Also the iterator and toArray methods iterate and return array in
sorted order.
 Additional Services provided:
◦ SortedSet <Element> subSet (Element fromElement, Element toElement);
◦ SortedSet <Element> headSet (Element toElement);
◦ SortedSet <Element> tailSet (Element fromElement);
◦ element first();
◦ element last();
◦ Comparator <? Super Element> comparator();
 Organizes data in ascending order based on natural
ordering of the keys or a comparator supplied at
instantiation time.
 Services provided in addition to Map interface:
◦ Comparator <? super Key> comparator();
◦ SortedMap<Key, Value> SubMap(Key from, key to);
◦ SortedMap<Key, Value> headMap (key to);
◦ SortedMap<Key, Value> tailMap(key from);
◦ Key firstKey();
◦ Key lastKey();
 ThreadSafety
◦ The bulk operations like keySet(), values() and entrySet()
return collections that can be modified automatically
when the underlying collection changes.
 Collections by default are not threadsafe
 In order to achieve thread-safety the following utility methods from
<collection> can be employed.
 Encapsulation
◦ Implementation style, where the access to the collection is only from a thread-safe
client
 Synchronization
◦ Collections.synchronizedList (new LinkedList(…));
 Unmodifiable
◦ Collections.unmodifiableList(new LinkedList(…));
 Fail-safe iterator
◦ Using fail-safe iterators makes sure the collection is not modified as it is iterated.

More Related Content

What's hot

Vector class in C++
Vector class in C++Vector class in C++
Vector class in C++
Jawad Khan
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
Barry DeCicco
 
Lec3
Lec3Lec3
Collections and generics
Collections and genericsCollections and generics
Collections and generics
Muthukumaran Subramanian
 
Spark 4th Meetup Londond - Building a Product with Spark
Spark 4th Meetup Londond - Building a Product with SparkSpark 4th Meetup Londond - Building a Product with Spark
Spark 4th Meetup Londond - Building a Product with Spark
samthemonad
 
Scala collection
Scala collectionScala collection
Scala collection
Knoldus Inc.
 
Collection and framework
Collection and frameworkCollection and framework
Collection and framework
SARAVANAN GOPALAKRISHNAN
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
Lifna C.S
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
Prof. Dr. K. Adisesha
 
Linked lists
Linked listsLinked lists
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
Akila Krishnamoorthy
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
Lifna C.S
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
Jason Larsen
 
Collection
CollectionCollection
Collection
Gayathri Ganesh
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
Aleksandras Smirnovas
 
Collections In Scala
Collections In ScalaCollections In Scala
Collections In Scala
Knoldus Inc.
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
Rajkiran Nadar
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In R
Rsquared Academy
 

What's hot (20)

Vector class in C++
Vector class in C++Vector class in C++
Vector class in C++
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
Lec3
Lec3Lec3
Lec3
 
Collections and generics
Collections and genericsCollections and generics
Collections and generics
 
Spark 4th Meetup Londond - Building a Product with Spark
Spark 4th Meetup Londond - Building a Product with SparkSpark 4th Meetup Londond - Building a Product with Spark
Spark 4th Meetup Londond - Building a Product with Spark
 
Scala collection
Scala collectionScala collection
Scala collection
 
Collection and framework
Collection and frameworkCollection and framework
Collection and framework
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
Collection
CollectionCollection
Collection
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
 
Collections In Scala
Collections In ScalaCollections In Scala
Collections In Scala
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In R
 
Scala collections
Scala collectionsScala collections
Scala collections
 

Viewers also liked

Database component in mule
Database component in muleDatabase component in mule
Database component in mule
javeed_mhd
 
How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint
javeed_mhd
 
Vm component in mule
Vm component in muleVm component in mule
Vm component in mule
javeed_mhd
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
javeed_mhd
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
javeed_mhd
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
javeed_mhd
 
Mule Esb
Mule EsbMule Esb
Mule Esb
javeed_mhd
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
javeed_mhd
 
Presentation
PresentationPresentation
Presentation
javeed_mhd
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
javeed_mhd
 
Java
JavaJava
web services
web servicesweb services
web services
javeed_mhd
 
Mule with rabbit mq
Mule with rabbit mq Mule with rabbit mq
Mule with rabbit mq
javeed_mhd
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
javeed_mhd
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
javeed_mhd
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
javeed_mhd
 
Simple groovy example in mule
Simple groovy example in muleSimple groovy example in mule
Simple groovy example in mule
javeed_mhd
 
Using xslt in mule
Using xslt in mule Using xslt in mule
Using xslt in mule
javeed_mhd
 

Viewers also liked (18)

Database component in mule
Database component in muleDatabase component in mule
Database component in mule
 
How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint
 
Vm component in mule
Vm component in muleVm component in mule
Vm component in mule
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
Mule Esb
Mule EsbMule Esb
Mule Esb
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Presentation
PresentationPresentation
Presentation
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Java
JavaJava
Java
 
web services
web servicesweb services
web services
 
Mule with rabbit mq
Mule with rabbit mq Mule with rabbit mq
Mule with rabbit mq
 
Cache for community edition
Cache for community edition Cache for community edition
Cache for community edition
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
 
Simple groovy example in mule
Simple groovy example in muleSimple groovy example in mule
Simple groovy example in mule
 
Using xslt in mule
Using xslt in mule Using xslt in mule
Using xslt in mule
 

Similar to collections

Collections
CollectionsCollections
Collections
Manav Prasad
 
Collections
CollectionsCollections
Collections
Rajkattamuri
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
Khasim Cise
 
Best core & advanced java classes in mumbai
Best core & advanced java classes in mumbaiBest core & advanced java classes in mumbai
Best core & advanced java classes in mumbai
Vibrant Technologies & Computers
 
JavaCollections.ppt
JavaCollections.pptJavaCollections.ppt
JavaCollections.ppt
boopathirajaraja1
 
JavaCollections.ppt
JavaCollections.pptJavaCollections.ppt
JavaCollections.ppt
Irfanhabeeb18
 
collectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptxcollectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptx
hemanth248901
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
Kenji HASUNUMA
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
Kenji HASUNUMA
 
java collections
java collectionsjava collections
java collections
javeed_mhd
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
ssuseredfbe9
 
07 java collection
07 java collection07 java collection
07 java collection
Abhishek Khune
 
List in java
List in javaList in java
List in java
nitin kumar
 
DSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdfDSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdf
Arumugam90
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
RashidFaridChishti
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
Debasish Pratihari
 
JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework
Jyothishmathi Institute of Technology and Science Karimnagar
 
Topic-G-JavaCollections Framework.ppt
Topic-G-JavaCollections    Framework.pptTopic-G-JavaCollections    Framework.ppt
Topic-G-JavaCollections Framework.ppt
swapnilslide2019
 
Java Collections
Java  Collections Java  Collections

Similar to collections (20)

Collections
CollectionsCollections
Collections
 
Collections
CollectionsCollections
Collections
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
 
Best core & advanced java classes in mumbai
Best core & advanced java classes in mumbaiBest core & advanced java classes in mumbai
Best core & advanced java classes in mumbai
 
JavaCollections.ppt
JavaCollections.pptJavaCollections.ppt
JavaCollections.ppt
 
JavaCollections.ppt
JavaCollections.pptJavaCollections.ppt
JavaCollections.ppt
 
collectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptxcollectionframework-141116005344-conversion-gate01.pptx
collectionframework-141116005344-conversion-gate01.pptx
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 
java collections
java collectionsjava collections
java collections
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
07 java collection
07 java collection07 java collection
07 java collection
 
List in java
List in javaList in java
List in java
 
DSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdfDSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdf
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework
 
Topic-G-JavaCollections Framework.ppt
Topic-G-JavaCollections    Framework.pptTopic-G-JavaCollections    Framework.ppt
Topic-G-JavaCollections Framework.ppt
 
Java Collections
Java  Collections Java  Collections
Java Collections
 

More from javeed_mhd

For each component in mule
For each component in muleFor each component in mule
For each component in mule
javeed_mhd
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
javeed_mhd
 
File component in mule
File component in muleFile component in mule
File component in mule
javeed_mhd
 
Choice component in mule
Choice component in muleChoice component in mule
Choice component in mule
javeed_mhd
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
javeed_mhd
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mule
javeed_mhd
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation
javeed_mhd
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy
javeed_mhd
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
javeed_mhd
 
How to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudioHow to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudio
javeed_mhd
 
Mapping and listing with mule
Mapping and listing with mule Mapping and listing with mule
Mapping and listing with mule
javeed_mhd
 
Mule any point exchange
Mule any point exchangeMule any point exchange
Mule any point exchange
javeed_mhd
 
Mule esb api layer
Mule esb api layer Mule esb api layer
Mule esb api layer
javeed_mhd
 
Mule Maven Plugin
Mule Maven PluginMule Maven Plugin
Mule Maven Plugin
javeed_mhd
 
Deploying and running in mule standalone
Deploying and running in mule standaloneDeploying and running in mule standalone
Deploying and running in mule standalone
javeed_mhd
 
Scatter gather in mule
Scatter gather in muleScatter gather in mule
Scatter gather in mule
javeed_mhd
 
Maven
MavenMaven
Maven
javeed_mhd
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
javeed_mhd
 
WebServices using Soapui
WebServices using SoapuiWebServices using Soapui
WebServices using Soapui
javeed_mhd
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
javeed_mhd
 

More from javeed_mhd (20)

For each component in mule
For each component in muleFor each component in mule
For each component in mule
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
 
File component in mule
File component in muleFile component in mule
File component in mule
 
Choice component in mule
Choice component in muleChoice component in mule
Choice component in mule
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mule
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
How to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudioHow to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudio
 
Mapping and listing with mule
Mapping and listing with mule Mapping and listing with mule
Mapping and listing with mule
 
Mule any point exchange
Mule any point exchangeMule any point exchange
Mule any point exchange
 
Mule esb api layer
Mule esb api layer Mule esb api layer
Mule esb api layer
 
Mule Maven Plugin
Mule Maven PluginMule Maven Plugin
Mule Maven Plugin
 
Deploying and running in mule standalone
Deploying and running in mule standaloneDeploying and running in mule standalone
Deploying and running in mule standalone
 
Scatter gather in mule
Scatter gather in muleScatter gather in mule
Scatter gather in mule
 
Maven
MavenMaven
Maven
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
WebServices using Soapui
WebServices using SoapuiWebServices using Soapui
WebServices using Soapui
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

collections

  • 2.  A Collection is a container that groups similar elements into an entity.  Examples would include a list of bank accounts, set of students, group of telephone numbers.  The Collections framework in Java offers a unified approach to store, retrieve and manipulate a group of data  Java’s Collection framework has an intuitive approach when compared to other complex frameworks such as C++
  • 3.  Helpful to developers by providing all standard data structures algorithms to let the developer concentrate more on functionality rather than the lower level details  Faster execution: with a range of options available for choice of implementation. The framework aids in improving the quality and performance of Java applications.  Code to interface: Since the collections framework is coded on the principles of “Code to Interface”, it aids in inter-operability between APIs that are not directly related.  Learning Curve: Easy to learn and start using Collections due to the “Code to Interface” principles.
  • 4.  The Collection framework forms a suitable hierarchy: Collection Set List Queue SortedSet Map SortedMap
  • 5.  The core Collections framework is very generic in nature and provides a standard interface to all operations that can be performed.  For example the root interface Collection is declared as public interface Collection <E> ◦ E represents a generic object.  Collection: This interface is pretty much used in declarations and method signatures so any type of Collections can be passed around.  Set: A Collection interface that cannot take any duplicate elements.  List: An ordered Collection interface that allows duplicate elements and provides object retrieval based on an integer index.  Queue: Apart from following the FIFO (First In First Out) principles this Collection offers variety of implementation.  Map: Supports Collection of key and value pairs. Design does not allow duplicate keys.  Sorted Set: Ordered version of the set interface.  Sorted Map: Maintains ascending order of keys.
  • 6.  boolean isEmpty();  boolean contains (Object element);  boolean remove (Object element);  Interface <E> iterator();  boolean containsAll (Collection <> C);  boolean addAll (Collection <? extends E> C);  boolean removeAll (Collection() > C); c.removeAll (Collections.Singleton(obj);  boolean retainAll (Collection <?> C);  void clear();  Object[ ] toArray();  <T> T[ ] toArray(T[ ]a);
  • 7.  Two ways to iterate over Collections: ◦ Iterator static void loopThrough(Collection col){ for (Iterator <E> iter = col.iterator();iter.hasnext()) { Object obj=iter.next(); } } ◦ For-each static void loopThrough(Collection col){ for (Object obj: col) { //access object } }
  • 8.  Set Interface: It offers inherited services from the root Collection interface with the added functionality of restricting duplicate elements.  Implementations: Set HashSet TreeSet LinkedHashSet
  • 9.  Adding unique objects to a collection Collection <String> uniqueString (Collection<String> c) { Set<String> uniqueSetStr = new HashSet<String>(); for (String str: c) { if(!uniqueStrSet.add(str)){ System.out.println(“Duplicate deleted:”+ str); } } return uniqueStrSet;
  • 10.  Idioms for using bulk operations on sets:  Copy a set when doing bulk operations to retain the original set.  Example: Set <String> unionSet = new TreeSet<String>(set1); unionSet.addAll(set2); HashSet TreeSet Linked HashSet Storage Type Hash Table Red-Black Tree Hash Table with a Linked List Performance Best performance Slower than HashSet Little costly than HashSet Order of Iteration No guarantee of order of iteration Order based Orders elements based on insertion
  • 11.  In addition to the core services inherited from the root collection interface, the list interface offers ◦ Positional access ◦ Search ◦ Customized Iteration ◦ Range-view  List Implementation ◦ ArrayList offers better performance compared to Linkedlist. List Arraylist Vector Linkedlist
  • 12.  Bulk Operations ◦ listA.addAll(listB); // append elements.  Positional access and search ◦ Eg: To swap elements in a list. public static<String> void swap(List<String>strList, int k, int l) { String strTmp = strList.get(l); strList.set(k,strList.get(l)); strList.set(l,strTmp); }
  • 13.  Customized Iteration: ListIterator ◦ Offers iteration in both directions, forward and backward ◦ Example: for(ListIterator<String> lIter=strList.listIterator(strList.size());lIter.hasPrevious()) { String str = lIter.previous(); }
  • 14.  Range-View: ◦ subList(int from, int to) returns a view portion of the sublist starting from <from> to <to> exclusive.
  • 15.  sort: Uses mergesort  shuffle: Randomly shuffles elements  reverse: Reverses order of elements  rotate: Rotates list by specified number  fill: Overwrites every element with specified element.  copy: Copies source list into destination.  binarySearch: Performs search usng binary search.  indexOfSubList: Returns index of first subList found.  lastIndexOfSubList: Returns index of the last subList found.
  • 16.  In addition to the inherited core services offered by Collection, queue offers following methods in two flavors: Purpose Throw Exception Return Special Value Insert Inserts an elements to the queue add(obj) offer(obj) Remove Remove head of the queue and return it. remove() poll() Examine Return the head of the queue element() peek()
  • 17.  Basic operations: ◦ Val put (Object key); ◦ Val get (Object key); ◦ Val remove (Object key); ◦ boolean containsKey (Object key); ◦ boolean containsValue (Object value); ◦ int size(); ◦ boolean isEmpty();  Bulk services ◦ Void putAll(Map<? extends Key, ? extends Val> map); ◦ void clear();
  • 18.  Views public set<Key> keySet(); public collection<Val> values(); public set<Maps.Entry<Key,Val>> entrySet();  Examples: Iteration over a map for(Map.Entry<?,vtype> elem: map.entrySet()) System.out.print(element.getKey()+”:”+element.getValue()); To find If a map contains another map If(map1.entrySet().containsAll(Map2.entrySet())) If two map objects contain same keys If(map1.keyset().equals(map2.keyset())) To find out common keys behave two map objects Set<Ktype> common keys = new Hashset<Ktype>(map1.commonkeys.retainAll(map2.keyset());
  • 20.  SortedSet stores elements in ascending order as per the natural ordering or as defined by a comparator provided at instantiation time.  Also the iterator and toArray methods iterate and return array in sorted order.  Additional Services provided: ◦ SortedSet <Element> subSet (Element fromElement, Element toElement); ◦ SortedSet <Element> headSet (Element toElement); ◦ SortedSet <Element> tailSet (Element fromElement); ◦ element first(); ◦ element last(); ◦ Comparator <? Super Element> comparator();
  • 21.  Organizes data in ascending order based on natural ordering of the keys or a comparator supplied at instantiation time.  Services provided in addition to Map interface: ◦ Comparator <? super Key> comparator(); ◦ SortedMap<Key, Value> SubMap(Key from, key to); ◦ SortedMap<Key, Value> headMap (key to); ◦ SortedMap<Key, Value> tailMap(key from); ◦ Key firstKey(); ◦ Key lastKey();
  • 22.  ThreadSafety ◦ The bulk operations like keySet(), values() and entrySet() return collections that can be modified automatically when the underlying collection changes.
  • 23.  Collections by default are not threadsafe  In order to achieve thread-safety the following utility methods from <collection> can be employed.  Encapsulation ◦ Implementation style, where the access to the collection is only from a thread-safe client  Synchronization ◦ Collections.synchronizedList (new LinkedList(…));  Unmodifiable ◦ Collections.unmodifiableList(new LinkedList(…));  Fail-safe iterator ◦ Using fail-safe iterators makes sure the collection is not modified as it is iterated.