SlideShare a Scribd company logo
1 of 6
Download to read offline
Core Java

Debasish Pratihari

Collection:


A collection is a generic term for any object that
represents a set of objects grouped together by
some means or mechanism inside the memory.



Collection Framework is a specification by which
we can store and manage objects of
heterogeneous kinds in memory.



 Collection Classes
are also called
Container classes

We can define collection as a java data structure
capable of storing & managing different kinds of
objects.



Note :

A collection has a capacity to grow dynamically.

Collection Framework Provides:


Interface



Implementation



Algorithms

Core Interfaces :

Collection

Set

List

Map

SortedMap

Queue

SortedSet

Lecture/core/collection/24

Page #1

feel the Technology…
Core Java

Debasish Pratihari

Types of Collection:


The way a collection (group of objects) is
implemented in memory, accordingly it is
categorized into following categories.

 Set
 List
 Map

Traversing Collections:


The Followings are the ways to traverse a
collection:





For-each loop
Iterator
ListItetor
Using Methods taking index as
Parameter

Collection Interfaces and Classes :
Interface Implementation
HashSet
Set
TreeSet
ArrayList
List
LinkedList
HashMap
Map
TreeMap

Lecture/core/collection/24

Historical

Vector
Stack
Hashtable
Properties

Page #2

feel the Technology…
Core Java

Debasish Pratihari

Collection Interface:
Methods
public
public
public
public
public
public
public
public
public











Iterator iterator ()
boolean add (Object obj)
boolean addAll (Collection other)
boolean remove (Object obj)
void clear( )
boolean isEmpty ( )
boolean contains (Object obj)
boolean containsAll (collection other)
int size ( )

Iterator interface :


Used for traverse a Collection in forward
direction.

Methods





public
public
public
public

boolean hasNext( )
Object next( )
Object next( )
Object remove ( )

ListIterator interface :


ListIterator interface in extended from Iterator
interface.
 In contrast to Iterator interface ListIterator
interface is used to traverse a collection in
forward or backward.
Method





public
public
public
public

Object next( )
 public boolean hasPrevious( )
boolean hasNext( )  public Object remove( )
Object remove( )
 public boolean add(Object obj)
Object previous( )  public boolean set(Object obj)

Lecture/core/collection/24

Page #3

feel the Technology…
Core Java

Debasish Pratihari

List Interface

Methods







public
public
public
public
public
public

ListIterator listIterator( )
void add(int index, Object obj)
void addAll(int i, Collection list)
Object remove(int indx)
Object set(int indx, Object obj)
int indexOf (Object obj)

Using Set :
25% 

Support basic operation of Collection Interface



Can’t contain duplicate elements.



Implementations





HasSet
TreeSet
LinkedHashSet

Example :
import java.util.*;
class SetDemo{
public static void main(String args[]){
HashSet <String>set= new HashSet<String>();
set.add("one");
set.add("two");
set.add("three");
set.add("four");
set.add("five");
System.out.println(set);
}
}

Lecture/core/collection/24

Page #4

feel the Technology…
Core Java

Debasish Pratihari

Using List :


Supports basic operations of Collection
Interface.



Facilitate positional access and Searching.



Supports range operation.



Implementations:



ArrayList
LinkedList

Example:

import java.util.*;
class ListDemo{
public static void main(String args[]){
LinkedList<Integer> list= new LinkedList<Integer>();

list.add(10);
list.add(20);
list.add(30);
System.out.println(list);
ListIterator itr= list.listIterator();
while(itr.hasNext())
System.out.println(itr.next());
while(itr.hasPrevious())
System.out.println(itr.previous());
}
}

Lecture/core/collection/24

Page #5

feel the Technology…
Core Java

Debasish Pratihari

Using Map :


Elements are stored as key-value pair



A map can’t contain duplicate keys



Accept null as key value.



Implementations:




HashMap
TreeMap
LinkedHashMap

Example :
import java.util.*;
class MapDemo{
public static void main(String args[]){
HashMap<String,String> map
= new HashMap<String,String>();

map.put("one","java");
map.put("two","j2ee");
map.put("three","struts");
map.put("four","hibernate");
map.put("","EJB");
System.out.println(map);
}
}
HashTable vs HashMap :
HashTable
 Synchronized
 Doesn’t accept null
 Order is maintained

Lecture/core/collection/24

vs

HashMap




Un-synchronized
Accept null
No guarantee of
order

Page #6

feel the Technology…

More Related Content

What's hot

Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)SURBHI SAROHA
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List Hitesh-Java
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets Hitesh-Java
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in javaAtul Sehdev
 
Java Serialization Deep Dive
Java Serialization Deep DiveJava Serialization Deep Dive
Java Serialization Deep DiveMartijn Dashorst
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsFrançois Garillot
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanZeeshan Khan
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in pythonSantosh Verma
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Hitesh-Java
 
Java Collections Framework
Java  Collections  FrameworkJava  Collections  Framework
Java Collections Frameworkguestd8c458
 

What's hot (20)

Object and class
Object and classObject and class
Object and class
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Java Serialization Deep Dive
Java Serialization Deep DiveJava Serialization Deep Dive
Java Serialization Deep Dive
 
Java Unit 2(part 3)
Java Unit 2(part 3)Java Unit 2(part 3)
Java Unit 2(part 3)
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on Steroids
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshan
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics
 
Java Collections Framework
Java  Collections  FrameworkJava  Collections  Framework
Java Collections Framework
 
Core & advanced java classes in mumbai
Core & advanced java classes in mumbaiCore & advanced java classes in mumbai
Core & advanced java classes in mumbai
 

Viewers also liked

Pedalando - 09.12.07
Pedalando - 09.12.07Pedalando - 09.12.07
Pedalando - 09.12.07Jubrac Jacui
 
090703 Sns Miyamura
090703 Sns Miyamura090703 Sns Miyamura
090703 Sns Miyamurayuu_2003
 
IT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy ComputersIT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy ComputersPaul McElvaney
 
Social media school 2011 webversie
Social media school 2011 webversieSocial media school 2011 webversie
Social media school 2011 webversieSjef Kerkhofs
 
javaday 2006 - Tiger
javaday 2006 - Tigerjavaday 2006 - Tiger
javaday 2006 - TigerMatteo Baccan
 
Deborah Limb, Learning Pool
Deborah Limb, Learning PoolDeborah Limb, Learning Pool
Deborah Limb, Learning PoolPaul McElvaney
 
The Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization EdittedThe Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization Edittedguestecd0c6
 
Time Saving Techniques Using Author-It
Time Saving Techniques Using Author-ItTime Saving Techniques Using Author-It
Time Saving Techniques Using Author-ItRhonda Bracey
 
Python e 10 motivos por que devo conhece-la ?
Python e 10 motivos por que devo conhece-la ?Python e 10 motivos por que devo conhece-la ?
Python e 10 motivos por que devo conhece-la ?Marcel Caraciolo
 
Pelajaran 1 Bm
Pelajaran 1 BmPelajaran 1 Bm
Pelajaran 1 Bmamoi286
 
Web-Technologies 26.06.2003
Web-Technologies 26.06.2003Web-Technologies 26.06.2003
Web-Technologies 26.06.2003Wolfgang Wiese
 
Google既有商業模式的破壞者3
Google既有商業模式的破壞者3Google既有商業模式的破壞者3
Google既有商業模式的破壞者3guestc1eec3
 

Viewers also liked (20)

Cradle To Cradle Kort
Cradle To Cradle KortCradle To Cradle Kort
Cradle To Cradle Kort
 
Pedalando - 09.12.07
Pedalando - 09.12.07Pedalando - 09.12.07
Pedalando - 09.12.07
 
Gai
GaiGai
Gai
 
090703 Sns Miyamura
090703 Sns Miyamura090703 Sns Miyamura
090703 Sns Miyamura
 
IT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy ComputersIT User Apprenticeship at Happy Computers
IT User Apprenticeship at Happy Computers
 
Social media school 2011 webversie
Social media school 2011 webversieSocial media school 2011 webversie
Social media school 2011 webversie
 
javaday 2006 - Tiger
javaday 2006 - Tigerjavaday 2006 - Tiger
javaday 2006 - Tiger
 
Deborah Limb, Learning Pool
Deborah Limb, Learning PoolDeborah Limb, Learning Pool
Deborah Limb, Learning Pool
 
It is All True
It is All TrueIt is All True
It is All True
 
The Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization EdittedThe Eastern Origins Of Western Civilization Editted
The Eastern Origins Of Western Civilization Editted
 
Ana Myspace
Ana MyspaceAna Myspace
Ana Myspace
 
Time Saving Techniques Using Author-It
Time Saving Techniques Using Author-ItTime Saving Techniques Using Author-It
Time Saving Techniques Using Author-It
 
Acampa2007
Acampa2007Acampa2007
Acampa2007
 
Visual Art
Visual ArtVisual Art
Visual Art
 
Python e 10 motivos por que devo conhece-la ?
Python e 10 motivos por que devo conhece-la ?Python e 10 motivos por que devo conhece-la ?
Python e 10 motivos por que devo conhece-la ?
 
My Brain Hurts by Y&R
My Brain Hurts by Y&RMy Brain Hurts by Y&R
My Brain Hurts by Y&R
 
Pelajaran 1 Bm
Pelajaran 1 BmPelajaran 1 Bm
Pelajaran 1 Bm
 
Web-Technologies 26.06.2003
Web-Technologies 26.06.2003Web-Technologies 26.06.2003
Web-Technologies 26.06.2003
 
Scmad Chapter08
Scmad Chapter08Scmad Chapter08
Scmad Chapter08
 
Google既有商業模式的破壞者3
Google既有商業模式的破壞者3Google既有商業模式的破壞者3
Google既有商業模式的破壞者3
 

Similar to Lecture 24

Collection framework
Collection frameworkCollection framework
Collection frameworkDilvarSingh2
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.pptNaitikChatterjee
 
Advanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxAdvanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxeyemitra1
 
Collections in java
Collections in javaCollections in java
Collections in javakejpretkopet
 
DSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdfDSJ_Unit III_Collection framework.pdf
DSJ_Unit III_Collection framework.pdfArumugam90
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in javaCPD INDIA
 
Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & setsRatnaJava
 
Collections and generic class
Collections and generic classCollections and generic class
Collections and generic classifis
 
Week_2_Lec_6-10_with_watermarking_(1).pdf
Week_2_Lec_6-10_with_watermarking_(1).pdfWeek_2_Lec_6-10_with_watermarking_(1).pdf
Week_2_Lec_6-10_with_watermarking_(1).pdfPrabhaK22
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionssuseredfbe9
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptxSoniaKapoor56
 
Generic Programming &amp; Collection
Generic Programming &amp; CollectionGeneric Programming &amp; Collection
Generic Programming &amp; CollectionArya
 
Generic Programming &amp; Collection
Generic Programming &amp; CollectionGeneric Programming &amp; Collection
Generic Programming &amp; CollectionArya
 
java collections
java collectionsjava collections
java collectionsjaveed_mhd
 
Collectn framework copy
Collectn framework   copyCollectn framework   copy
Collectn framework copycharan kumar
 
Collectn framework
Collectn frameworkCollectn framework
Collectn frameworkcharan kumar
 

Similar to Lecture 24 (20)

Collection framework
Collection frameworkCollection framework
Collection framework
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt
 
Advanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptxAdvanced Java - UNIT 3.pptx
Advanced Java - UNIT 3.pptx
 
collections
collectionscollections
collections
 
Collections
CollectionsCollections
Collections
 
Collections in java
Collections in javaCollections in java
Collections 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
 
Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & sets
 
Collections and generic class
Collections and generic classCollections and generic class
Collections and generic class
 
Week_2_Lec_6-10_with_watermarking_(1).pdf
Week_2_Lec_6-10_with_watermarking_(1).pdfWeek_2_Lec_6-10_with_watermarking_(1).pdf
Week_2_Lec_6-10_with_watermarking_(1).pdf
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptx
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Generic Programming &amp; Collection
Generic Programming &amp; CollectionGeneric Programming &amp; Collection
Generic Programming &amp; Collection
 
Generic Programming &amp; Collection
Generic Programming &amp; CollectionGeneric Programming &amp; Collection
Generic Programming &amp; Collection
 
java collections
java collectionsjava collections
java collections
 
Collectn framework copy
Collectn framework   copyCollectn framework   copy
Collectn framework copy
 
Collectn framework
Collectn frameworkCollectn framework
Collectn framework
 
JavaCollections.ppt
JavaCollections.pptJavaCollections.ppt
JavaCollections.ppt
 

More from Debasish Pratihari (19)

Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
🐬 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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
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
 
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
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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)
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 

Lecture 24

  • 1. Core Java Debasish Pratihari Collection:  A collection is a generic term for any object that represents a set of objects grouped together by some means or mechanism inside the memory.  Collection Framework is a specification by which we can store and manage objects of heterogeneous kinds in memory.   Collection Classes are also called Container classes We can define collection as a java data structure capable of storing & managing different kinds of objects.  Note : A collection has a capacity to grow dynamically. Collection Framework Provides:  Interface  Implementation  Algorithms Core Interfaces : Collection Set List Map SortedMap Queue SortedSet Lecture/core/collection/24 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari Types of Collection:  The way a collection (group of objects) is implemented in memory, accordingly it is categorized into following categories.  Set  List  Map Traversing Collections:  The Followings are the ways to traverse a collection:     For-each loop Iterator ListItetor Using Methods taking index as Parameter Collection Interfaces and Classes : Interface Implementation HashSet Set TreeSet ArrayList List LinkedList HashMap Map TreeMap Lecture/core/collection/24 Historical Vector Stack Hashtable Properties Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari Collection Interface: Methods public public public public public public public public public          Iterator iterator () boolean add (Object obj) boolean addAll (Collection other) boolean remove (Object obj) void clear( ) boolean isEmpty ( ) boolean contains (Object obj) boolean containsAll (collection other) int size ( ) Iterator interface :  Used for traverse a Collection in forward direction. Methods     public public public public boolean hasNext( ) Object next( ) Object next( ) Object remove ( ) ListIterator interface :  ListIterator interface in extended from Iterator interface.  In contrast to Iterator interface ListIterator interface is used to traverse a collection in forward or backward. Method     public public public public Object next( )  public boolean hasPrevious( ) boolean hasNext( )  public Object remove( ) Object remove( )  public boolean add(Object obj) Object previous( )  public boolean set(Object obj) Lecture/core/collection/24 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari List Interface Methods       public public public public public public ListIterator listIterator( ) void add(int index, Object obj) void addAll(int i, Collection list) Object remove(int indx) Object set(int indx, Object obj) int indexOf (Object obj) Using Set : 25%  Support basic operation of Collection Interface  Can’t contain duplicate elements.  Implementations    HasSet TreeSet LinkedHashSet Example : import java.util.*; class SetDemo{ public static void main(String args[]){ HashSet <String>set= new HashSet<String>(); set.add("one"); set.add("two"); set.add("three"); set.add("four"); set.add("five"); System.out.println(set); } } Lecture/core/collection/24 Page #4 feel the Technology…
  • 5. Core Java Debasish Pratihari Using List :  Supports basic operations of Collection Interface.  Facilitate positional access and Searching.  Supports range operation.  Implementations:   ArrayList LinkedList Example: import java.util.*; class ListDemo{ public static void main(String args[]){ LinkedList<Integer> list= new LinkedList<Integer>(); list.add(10); list.add(20); list.add(30); System.out.println(list); ListIterator itr= list.listIterator(); while(itr.hasNext()) System.out.println(itr.next()); while(itr.hasPrevious()) System.out.println(itr.previous()); } } Lecture/core/collection/24 Page #5 feel the Technology…
  • 6. Core Java Debasish Pratihari Using Map :  Elements are stored as key-value pair  A map can’t contain duplicate keys  Accept null as key value.  Implementations:    HashMap TreeMap LinkedHashMap Example : import java.util.*; class MapDemo{ public static void main(String args[]){ HashMap<String,String> map = new HashMap<String,String>(); map.put("one","java"); map.put("two","j2ee"); map.put("three","struts"); map.put("four","hibernate"); map.put("","EJB"); System.out.println(map); } } HashTable vs HashMap : HashTable  Synchronized  Doesn’t accept null  Order is maintained Lecture/core/collection/24 vs HashMap    Un-synchronized Accept null No guarantee of order Page #6 feel the Technology…