SlideShare a Scribd company logo
Java : Collection and
Introduction to
Generics
Developer Students Club - LNCT
What is collection ?
The image shows a collection of watches.
1. Intro
A collection is an object that represents a group of
objects (such as the classic Vector class). A
collections framework is a unified architecture for
representing and manipulating collections,
enabling collections to be manipulated
independently of implementation details.
Advantages of using
collection ?
Tip
In this question,
Think of real world
example
Try to think the
benefits of handling
things as a group.
Few advantages are
● Reduces programming effort by providing data structures and algorithms so
you don't have to write them yourself.
● Increases performance by providing high-performance implementations of data
structures and algorithms. Because the various implementations of each
interface are interchangeable, programs can be tuned by switching
implementations.
● Reduces the effort required to learn APIs by requiring you to learn multiple ad
hoc collection APIs.
● Reduces the effort required to design and implement APIs by not requiring
you to produce ad hoc collections APIs.
● Fosters software reuse by providing a standard interface for collections and
algorithms with which to manipulate them.
The collection framework
internally uses generics.
Let’s code to
understand the basics.
Tip
Open up a text editor
( gedit, Notepad )
and start typing hello
world program in
java
2. Examples
Hit the url :
https://github.com/Pradhan10/Java-Collections-and-Generics
➔ The difference between storing data in array vs arraylist ?
Start with drawing analogies to array in C.
➔ How are we printing all elements in arraylist ?
Did we write the for loop to iterate all elements in list
anywhere ?
Meet Joshua Bloch
He wrote most of the java Collection
framework and was chief architect in
development of language.
Story for illustration purposes only
The main interfaces of the Java Collections Framework
Why do you think
the map interface
was implemented
seperately ?
Tip
Look at the
mathematical
difference between
a set, a sequence
and a mapping.
Code example two
Hit the url :
https://github.com/Pradhan10/Java-Collections-a
nd-Generics/blob/master/QueueClass.java
Code example three
Hit url :
https://goo.gl/Md1
QAi
Generics
The main reasons for using
generics :
1 : Type safety
2 : Cast iron guarantee
Hit url :
https://goo.gl/a15ush
Cast-iron guarantee
The implicit casts added by
the compilation of generics
never fail. (applies only when no unchecked warnings have been issued
by the compiler.)
Generics in action
The 3 most used type parameters
1 : <E>, <T>, <K, V> (Used in Map interface)
2 : ? extends E (Used in iterator class)
3 : ? super T (Used in Comparator method)
Wildcard capture (?), add members of collection that
are subtype of E
Wildcard capture (?), destination may have elements
of any subtype of T
Feedback please :
https://goo.gl/cjJoJN
DSC Mail :
appliedcs.lnct@gmail.com
LinkedIn :
https://www.linkedin.com
/in/pradhan-rishi-sharma1
0
Thank you !

More Related Content

Similar to JAVA Collection and generics (20)

PPTX
VTUOOPMCA5THMODULECollection OverV .pptx
VeenaNaik23
 
PPTX
mca5thCollection OverViCollection O.pptx
VeenaNaik23
 
PPTX
VTUOOPMCA5THMODULEvCollection OverV.pptx
VeenaNaik23
 
PPTX
VTUOOPMCA5THMODULECollection OverVi.pptx
VeenaNaik23
 
PPTX
JAVA(UNIT 4)
Dr. SURBHI SAROHA
 
PDF
Java Collection Interview Questions [Updated]
SoniaMathias2
 
PPTX
Collection framework
BindhuBhargaviTalasi
 
PDF
JAVA PROGRAMMING - The Collections Framework
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Collections
Marwa Dosoky
 
PPT
Collection framework
DilvarSingh2
 
PDF
Generics and collections in Java
Gurpreet singh
 
PPT
Collections and generic class
ifis
 
PPTX
Java Collection Framework 2nd year B.Tech.pptx
kmd198809
 
PPTX
Java collections
anshkhurana7
 
PPTX
Java collections
Amar Kutwal
 
PPTX
Lecture 9
talha ijaz
 
PDF
Collection framework (completenotes) zeeshan
Zeeshan Khan
 
PPT
12_-_Collections_Framework
Krishna Sujeer
 
PDF
Generics in java
Sanju_Doraha
 
PPTX
Advanced Java - UNIT 3.pptx
eyemitra1
 
VTUOOPMCA5THMODULECollection OverV .pptx
VeenaNaik23
 
mca5thCollection OverViCollection O.pptx
VeenaNaik23
 
VTUOOPMCA5THMODULEvCollection OverV.pptx
VeenaNaik23
 
VTUOOPMCA5THMODULECollection OverVi.pptx
VeenaNaik23
 
JAVA(UNIT 4)
Dr. SURBHI SAROHA
 
Java Collection Interview Questions [Updated]
SoniaMathias2
 
Collection framework
BindhuBhargaviTalasi
 
JAVA PROGRAMMING - The Collections Framework
Jyothishmathi Institute of Technology and Science Karimnagar
 
Collections
Marwa Dosoky
 
Collection framework
DilvarSingh2
 
Generics and collections in Java
Gurpreet singh
 
Collections and generic class
ifis
 
Java Collection Framework 2nd year B.Tech.pptx
kmd198809
 
Java collections
anshkhurana7
 
Java collections
Amar Kutwal
 
Lecture 9
talha ijaz
 
Collection framework (completenotes) zeeshan
Zeeshan Khan
 
12_-_Collections_Framework
Krishna Sujeer
 
Generics in java
Sanju_Doraha
 
Advanced Java - UNIT 3.pptx
eyemitra1
 

More from Pradhan Rishi Sharma (20)

PDF
JAVA Threads explained
Pradhan Rishi Sharma
 
PDF
Plasma TFT
Pradhan Rishi Sharma
 
ODP
Inheritance
Pradhan Rishi Sharma
 
PDF
Inheritance
Pradhan Rishi Sharma
 
PDF
0/1Knapsack
Pradhan Rishi Sharma
 
PDF
Computer system architecture
Pradhan Rishi Sharma
 
PPTX
Aids Awareness , Nss , Healthcare !
Pradhan Rishi Sharma
 
ODP
D Flip Flop
Pradhan Rishi Sharma
 
ODP
Optical fiber
Pradhan Rishi Sharma
 
PPT
Optical Fiber
Pradhan Rishi Sharma
 
PPTX
Algorithms
Pradhan Rishi Sharma
 
PPT
Algorithms
Pradhan Rishi Sharma
 
ODP
Algorithms
Pradhan Rishi Sharma
 
ODP
Algorithms
Pradhan Rishi Sharma
 
PPTX
Solar Energy
Pradhan Rishi Sharma
 
PDF
Solar Energy
Pradhan Rishi Sharma
 
ODP
Solar Energy
Pradhan Rishi Sharma
 
PPTX
Beam , support and reaction
Pradhan Rishi Sharma
 
ODP
Beam , support and reaction
Pradhan Rishi Sharma
 
JAVA Threads explained
Pradhan Rishi Sharma
 
Computer system architecture
Pradhan Rishi Sharma
 
Aids Awareness , Nss , Healthcare !
Pradhan Rishi Sharma
 
D Flip Flop
Pradhan Rishi Sharma
 
Optical fiber
Pradhan Rishi Sharma
 
Optical Fiber
Pradhan Rishi Sharma
 
Solar Energy
Pradhan Rishi Sharma
 
Solar Energy
Pradhan Rishi Sharma
 
Solar Energy
Pradhan Rishi Sharma
 
Beam , support and reaction
Pradhan Rishi Sharma
 
Beam , support and reaction
Pradhan Rishi Sharma
 
Ad

Recently uploaded (20)

PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PDF
Next level data operations using Power Automate magic
Andries den Haan
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
Next level data operations using Power Automate magic
Andries den Haan
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Practical Applications of AI in Local Government
OnBoard
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Ad

JAVA Collection and generics

  • 1. Java : Collection and Introduction to Generics Developer Students Club - LNCT
  • 2. What is collection ? The image shows a collection of watches.
  • 3. 1. Intro A collection is an object that represents a group of objects (such as the classic Vector class). A collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details.
  • 4. Advantages of using collection ? Tip In this question, Think of real world example Try to think the benefits of handling things as a group.
  • 5. Few advantages are ● Reduces programming effort by providing data structures and algorithms so you don't have to write them yourself. ● Increases performance by providing high-performance implementations of data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be tuned by switching implementations. ● Reduces the effort required to learn APIs by requiring you to learn multiple ad hoc collection APIs. ● Reduces the effort required to design and implement APIs by not requiring you to produce ad hoc collections APIs. ● Fosters software reuse by providing a standard interface for collections and algorithms with which to manipulate them.
  • 6. The collection framework internally uses generics. Let’s code to understand the basics. Tip Open up a text editor ( gedit, Notepad ) and start typing hello world program in java
  • 7. 2. Examples Hit the url : https://github.com/Pradhan10/Java-Collections-and-Generics ➔ The difference between storing data in array vs arraylist ? Start with drawing analogies to array in C. ➔ How are we printing all elements in arraylist ? Did we write the for loop to iterate all elements in list anywhere ?
  • 8. Meet Joshua Bloch He wrote most of the java Collection framework and was chief architect in development of language.
  • 9. Story for illustration purposes only The main interfaces of the Java Collections Framework
  • 10. Why do you think the map interface was implemented seperately ? Tip Look at the mathematical difference between a set, a sequence and a mapping.
  • 11. Code example two Hit the url : https://github.com/Pradhan10/Java-Collections-a nd-Generics/blob/master/QueueClass.java
  • 12. Code example three Hit url : https://goo.gl/Md1 QAi
  • 14. The main reasons for using generics : 1 : Type safety 2 : Cast iron guarantee
  • 16. Cast-iron guarantee The implicit casts added by the compilation of generics never fail. (applies only when no unchecked warnings have been issued by the compiler.)
  • 18. The 3 most used type parameters 1 : <E>, <T>, <K, V> (Used in Map interface) 2 : ? extends E (Used in iterator class) 3 : ? super T (Used in Comparator method)
  • 19. Wildcard capture (?), add members of collection that are subtype of E
  • 20. Wildcard capture (?), destination may have elements of any subtype of T
  • 22. DSC Mail : [email protected] LinkedIn : https://www.linkedin.com /in/pradhan-rishi-sharma1 0