SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Processing Data
in Collections
Chapter 13
13
Object Wrappers
Collections can only hold objects.
Primitive types (int, double, float,etc.)
are not objects.
Primitives must be wrapped in special
wrapper objects.
Wrappers exist for each of the eight
primitive types.
13
What is an iterator?
An iterator is an object that
encapsulates the ability to iterate
through or visit each element in the
collection.
13
Using the Iterator Interface
hasNext() method determines if there
are more elements in the array
next() method returns the next element
and advances the iterator
13
The DrawShapes Application
User clicks in applet window to create
one of three random shapes.
Each shape is added to a collection.
When user clicks in applet window, the
collection is checked to see if a “hit” is
registered on an existing shape.
When a “hit” occurs, the shape’s color
will change randomly.
13
The Shape Inheritance Hierarchy
Abstract class OurShape implements:
changeColorRandomly() to change the
color of an object by randomly selecting a
color
contains() to determine whether x, y
coordinates of a mouse click fall within a
shape’s boundaries
draw() to draw the shape at x, y
coordinates specified by a mouse click
13
Classes Derived from OurShape
OurRectangle
OurTriangle
OurCircle
13
What is a linked list?
A LinkedList is a more powerful data
structure that allows for quick and
easy insertion and removal of
elements.
13
Linked Lists
LinkedLists come in two types:
Singly linked list—each node knows only
the next node
Doubly linked list—each node knows both
the previous and the next node
13
What is a set?
A set is a collection with no duplicate
elements.
Programmer needs to determine what
constitutes a “duplicate.”
The equals() method can be used to
provide an additional definition of
equality.
13
HashSet
Based on a hash table, a HashSet is a
powerful data structure that can be
used to retrieve objects quickly in a set.
Unordered collection
A hash code is used to organize objects
in a HashSet
13
TreeSet
TreeSet provides the properties of a set in
a sorted collection.
Objects can be inserted in any order but are
retrieved in sorted order
Uses Comparable interface to compare objects
for sorting
Primitive types and String objects are
comparable
Up to programmer to implement the
compareTo() method for user-defined objects

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (19)

List interface
List interfaceList interface
List interface
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
Slide 1.-datastructure
Slide 1.-datastructureSlide 1.-datastructure
Slide 1.-datastructure
 
collections
 collections collections
collections
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
structures and unions in 'C'
structures and unions in 'C'structures and unions in 'C'
structures and unions in 'C'
 
2 introduction to data structure
2  introduction to data structure2  introduction to data structure
2 introduction to data structure
 
5 Array List, data structure course
5 Array List, data structure course5 Array List, data structure course
5 Array List, data structure course
 
Java collections
Java collectionsJava collections
Java collections
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Orange Data Mining & Data Visualization Tool
Orange Data Mining & Data Visualization ToolOrange Data Mining & Data Visualization Tool
Orange Data Mining & Data Visualization Tool
 
Java collections
Java collectionsJava collections
Java collections
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
R data types
R   data typesR   data types
R data types
 
Data structures
Data structuresData structures
Data structures
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Presentation of array
Presentation of arrayPresentation of array
Presentation of array
 
Data struters
Data strutersData struters
Data struters
 

Andere mochten auch (7)

Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Enterprise Skills
Enterprise SkillsEnterprise Skills
Enterprise Skills
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Key enterprise skills
Key enterprise skillsKey enterprise skills
Key enterprise skills
 

Ähnlich wie Chapter 13

oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionssuseredfbe9
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections frameworkRiccardo Cardin
 
Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questionsyearninginjava
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.pptNaitikChatterjee
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - JavaDrishti Bhalla
 
List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections frameworkRavi Chythanya
 
introduction_dst.pptx
introduction_dst.pptxintroduction_dst.pptx
introduction_dst.pptxHammadTariq51
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanZeeshan Khan
 
Collection framework
Collection frameworkCollection framework
Collection frameworkDilvarSingh2
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptyarotos643
 

Ähnlich wie Chapter 13 (20)

oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
ArrayList.docx
ArrayList.docxArrayList.docx
ArrayList.docx
 
Java - Collections framework
Java - Collections frameworkJava - Collections framework
Java - Collections framework
 
Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questions
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt
 
Collection Framework-1.pptx
Collection Framework-1.pptxCollection Framework-1.pptx
Collection Framework-1.pptx
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Collections
CollectionsCollections
Collections
 
List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections framework
 
Collections framework
Collections frameworkCollections framework
Collections framework
 
introduction_dst.pptx
introduction_dst.pptxintroduction_dst.pptx
introduction_dst.pptx
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshan
 
javacollections.pdf
javacollections.pdfjavacollections.pdf
javacollections.pdf
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Core & advanced java classes in mumbai
Core & advanced java classes in mumbaiCore & advanced java classes in mumbai
Core & advanced java classes in mumbai
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Java collections
Java collectionsJava collections
Java collections
 

Mehr von Graham Royce (20)

Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
Chapter 06
Chapter 06Chapter 06
Chapter 06
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
 
My 3 min pitch pack
My 3 min pitch packMy 3 min pitch pack
My 3 min pitch pack
 
Things to do
Things to doThings to do
Things to do
 
House in order
House in orderHouse in order
House in order
 
Blank 10 all you need
Blank 10 all you needBlank 10 all you need
Blank 10 all you need
 
Goals
GoalsGoals
Goals
 
Idea's1 only
Idea's1 onlyIdea's1 only
Idea's1 only
 
New frontiers motivation
New frontiers motivationNew frontiers motivation
New frontiers motivation
 
The only slides you need
The only slides you needThe only slides you need
The only slides you need
 

Kürzlich hochgeladen

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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Kürzlich hochgeladen (20)

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...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Chapter 13

  • 2. 13 Object Wrappers Collections can only hold objects. Primitive types (int, double, float,etc.) are not objects. Primitives must be wrapped in special wrapper objects. Wrappers exist for each of the eight primitive types.
  • 3. 13 What is an iterator? An iterator is an object that encapsulates the ability to iterate through or visit each element in the collection.
  • 4. 13 Using the Iterator Interface hasNext() method determines if there are more elements in the array next() method returns the next element and advances the iterator
  • 5. 13 The DrawShapes Application User clicks in applet window to create one of three random shapes. Each shape is added to a collection. When user clicks in applet window, the collection is checked to see if a “hit” is registered on an existing shape. When a “hit” occurs, the shape’s color will change randomly.
  • 6. 13 The Shape Inheritance Hierarchy Abstract class OurShape implements: changeColorRandomly() to change the color of an object by randomly selecting a color contains() to determine whether x, y coordinates of a mouse click fall within a shape’s boundaries draw() to draw the shape at x, y coordinates specified by a mouse click
  • 7. 13 Classes Derived from OurShape OurRectangle OurTriangle OurCircle
  • 8. 13 What is a linked list? A LinkedList is a more powerful data structure that allows for quick and easy insertion and removal of elements.
  • 9. 13 Linked Lists LinkedLists come in two types: Singly linked list—each node knows only the next node Doubly linked list—each node knows both the previous and the next node
  • 10. 13 What is a set? A set is a collection with no duplicate elements. Programmer needs to determine what constitutes a “duplicate.” The equals() method can be used to provide an additional definition of equality.
  • 11. 13 HashSet Based on a hash table, a HashSet is a powerful data structure that can be used to retrieve objects quickly in a set. Unordered collection A hash code is used to organize objects in a HashSet
  • 12. 13 TreeSet TreeSet provides the properties of a set in a sorted collection. Objects can be inserted in any order but are retrieved in sorted order Uses Comparable interface to compare objects for sorting Primitive types and String objects are comparable Up to programmer to implement the compareTo() method for user-defined objects