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

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

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…