SlideShare a Scribd company logo
1 of 14
Collection Framework 
Day4 
Introduction 
Apex T. G. India Pvt. Ltd
1 
Map Interface
1 
Map Interface 
 It is introduced in 1.2 version of java. 
 It is based on key-value paired techniques(Hashing 
techniques). 
 It represents the three collection view one as a set of 
key,one as collection of values, or set of key-value 
mappings.
1 
Map Interface 
 We can say that it replace the deprecated abstract class 
Dictionary . 
 A map elements can't contains duplicate keys but can 
contain duplicate values. 
 It is non-synchronized.
1 
HashMap 
 It is used from 1.2 version of java. 
 It is based on key-value paired techniques(Hashing 
techniques). 
 It extends AbstractMap class and implements Cloneable and 
Serializable interface. 
 It Doesn't have any fix order for generating result ,even it 
does not guarantee that the order will remain constant over 
time.
1 
HashMap 
 It allow null key and value but can have only one null key 
and multiple null values. 
 Iteration cant be performed directly on Map elements.It is 
performed by generating collection view of Map. 
 HashMap class i.e nearly equivalent to Hashtable class by 
feature.
1 
Hashtable 
 It is used from Jdk1.0. 
 A Hashtable is an array of list. 
 Each list of array in hashtable known as a bucket. 
 Bucket position is identified by calling the method 
hashcode( ). 
 A Hashtable contains values based on the key means it is 
based on key-value pair.
1 
Hashtable 
 It implements the Map interface and extends Dictionary 
class. 
 It contains only unique elements. 
 It doesn’t have any null key or null value. 
 It is by default synchronized . 
 An instance of Hashtable has two parameters initial capacity 
and load factor that affect its performance.
1 
Hashtable 
 To successfully store and retrieve objects from a hashtable, 
the objects used as keys must implement the hashCode and 
equals method. 
 Simple capacity is the number of buckets in the hash table, 
and the initial capacity is simply the capacity at the time the 
hash table is created. Note that the hash table is open in 
case of a "hash collision", a single bucket stores multiple 
entries, which must be searched sequentially.
1 
Hashtable 
 The load factor is a measure of how full the hashtable is 
allowed to get before its capacity is automatically increased. 
 The initial capacity and load factor parameters are merely 
hints to the implementation. The exact details as to when 
and whether the rehash method is invoked are 
implementation-dependent.
1 
Hashtable 
 Generally, the default load factor (.75) offers a good tradeoff 
between time and space costs. Higher values decrease the 
space overhead but increase the time cost to look up an 
entry (which is reflected in most Hashtable operations, 
including get and put ). 
 The initial capacity controls a tradeoff between wasted 
space and the need for rehash operations, which are time-consuming.
1 
Hashtable 
 No rehash operations will ever occur if the initial capacity 
is greater than the maximum number of entries the 
Hashtable will contain divided by its load factor. However, 
setting the initial capacity too high can waste space. 
 If many entries are to be made into a Hashtable ,creating it 
with a sufficiently large capacity may allow the entries to be 
inserted more efficiently than letting it perform automatic 
rehashing as needed to grow the table.
1 
HashMap vs Hashtable 
 HashMap is not synchronized where as Hashtable 
is synchronized. 
 HashMap allow null key and null values where as Hashtable 
doesn't allow null key as well as null value,it will generate 
NullPoniterException when null is added. 
 Only one thread can take control over this if multiple 
threads want to take control over it then they have to 
maintain the queue that's why it is known as thread-safe.
Thanks 
Stay Connected with us for more chapters on JAVA 
facebook.com/apex.tgi 
twitter.com/ApextgiNoida 
pinterest.com/apextgi

More Related Content

Viewers also liked (8)

Msr300
Msr300Msr300
Msr300
 
Tr 069
Tr 069Tr 069
Tr 069
 
02 2014-tt-bgd quy che cong nhan truong mam non dat chuan qg
02 2014-tt-bgd quy che cong nhan truong mam non dat chuan qg02 2014-tt-bgd quy che cong nhan truong mam non dat chuan qg
02 2014-tt-bgd quy che cong nhan truong mam non dat chuan qg
 
ロシアのインターネット広告業界の紹介
ロシアのインターネット広告業界の紹介ロシアのインターネット広告業界の紹介
ロシアのインターネット広告業界の紹介
 
100 mcqs from al qur an
100 mcqs from al qur an100 mcqs from al qur an
100 mcqs from al qur an
 
PELAYANAN TERPADU KECAMATAN (PATEN)
PELAYANAN TERPADU KECAMATAN (PATEN)PELAYANAN TERPADU KECAMATAN (PATEN)
PELAYANAN TERPADU KECAMATAN (PATEN)
 
Maletinha magica projeto
Maletinha magica projetoMaletinha magica projeto
Maletinha magica projeto
 
Maletinha magica projeto
Maletinha magica projetoMaletinha magica projeto
Maletinha magica projeto
 

Similar to Reference Guide to Java - Day4

Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questions
yearninginjava
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
Arun Vasanth
 
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdfAssignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
kksrivastava1
 
Java collections
Java collectionsJava collections
Java collections
padmad2291
 

Similar to Reference Guide to Java - Day4 (20)

Java collections-interview-questions
Java collections-interview-questionsJava collections-interview-questions
Java collections-interview-questions
 
Java Collections.pptx
Java Collections.pptxJava Collections.pptx
Java Collections.pptx
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Hash table in java
Hash table in javaHash table in java
Hash table in java
 
unit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptxunit-1-dsa-hashing-2022_compressed-1-converted.pptx
unit-1-dsa-hashing-2022_compressed-1-converted.pptx
 
linear probing
linear probinglinear probing
linear probing
 
DS THEORY 35.pptx
DS THEORY 35.pptxDS THEORY 35.pptx
DS THEORY 35.pptx
 
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdfAssignment4 Assignment 4 Hashtables In this assignment we w.pdf
Assignment4 Assignment 4 Hashtables In this assignment we w.pdf
 
Data Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table pptData Structure and Algorithms: What is Hash Table ppt
Data Structure and Algorithms: What is Hash Table ppt
 
Collection in Java
Collection in JavaCollection in Java
Collection in Java
 
Hashing
HashingHashing
Hashing
 
Collections Java e Google Collections
Collections Java e Google CollectionsCollections Java e Google Collections
Collections Java e Google Collections
 
Javasession7
Javasession7Javasession7
Javasession7
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Md08 collection api
Md08 collection apiMd08 collection api
Md08 collection api
 
VCE Unit 04vv.pptx
VCE Unit 04vv.pptxVCE Unit 04vv.pptx
VCE Unit 04vv.pptx
 
Hashing data
Hashing dataHashing data
Hashing data
 
Chapter 10: hashing data structure
Chapter 10:  hashing data structureChapter 10:  hashing data structure
Chapter 10: hashing data structure
 
Java collections
Java collectionsJava collections
Java collections
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 

Recently uploaded

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
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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?
 
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
 
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
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
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...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 

Reference Guide to Java - Day4

  • 1. Collection Framework Day4 Introduction Apex T. G. India Pvt. Ltd
  • 3. 1 Map Interface  It is introduced in 1.2 version of java.  It is based on key-value paired techniques(Hashing techniques).  It represents the three collection view one as a set of key,one as collection of values, or set of key-value mappings.
  • 4. 1 Map Interface  We can say that it replace the deprecated abstract class Dictionary .  A map elements can't contains duplicate keys but can contain duplicate values.  It is non-synchronized.
  • 5. 1 HashMap  It is used from 1.2 version of java.  It is based on key-value paired techniques(Hashing techniques).  It extends AbstractMap class and implements Cloneable and Serializable interface.  It Doesn't have any fix order for generating result ,even it does not guarantee that the order will remain constant over time.
  • 6. 1 HashMap  It allow null key and value but can have only one null key and multiple null values.  Iteration cant be performed directly on Map elements.It is performed by generating collection view of Map.  HashMap class i.e nearly equivalent to Hashtable class by feature.
  • 7. 1 Hashtable  It is used from Jdk1.0.  A Hashtable is an array of list.  Each list of array in hashtable known as a bucket.  Bucket position is identified by calling the method hashcode( ).  A Hashtable contains values based on the key means it is based on key-value pair.
  • 8. 1 Hashtable  It implements the Map interface and extends Dictionary class.  It contains only unique elements.  It doesn’t have any null key or null value.  It is by default synchronized .  An instance of Hashtable has two parameters initial capacity and load factor that affect its performance.
  • 9. 1 Hashtable  To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode and equals method.  Simple capacity is the number of buckets in the hash table, and the initial capacity is simply the capacity at the time the hash table is created. Note that the hash table is open in case of a "hash collision", a single bucket stores multiple entries, which must be searched sequentially.
  • 10. 1 Hashtable  The load factor is a measure of how full the hashtable is allowed to get before its capacity is automatically increased.  The initial capacity and load factor parameters are merely hints to the implementation. The exact details as to when and whether the rehash method is invoked are implementation-dependent.
  • 11. 1 Hashtable  Generally, the default load factor (.75) offers a good tradeoff between time and space costs. Higher values decrease the space overhead but increase the time cost to look up an entry (which is reflected in most Hashtable operations, including get and put ).  The initial capacity controls a tradeoff between wasted space and the need for rehash operations, which are time-consuming.
  • 12. 1 Hashtable  No rehash operations will ever occur if the initial capacity is greater than the maximum number of entries the Hashtable will contain divided by its load factor. However, setting the initial capacity too high can waste space.  If many entries are to be made into a Hashtable ,creating it with a sufficiently large capacity may allow the entries to be inserted more efficiently than letting it perform automatic rehashing as needed to grow the table.
  • 13. 1 HashMap vs Hashtable  HashMap is not synchronized where as Hashtable is synchronized.  HashMap allow null key and null values where as Hashtable doesn't allow null key as well as null value,it will generate NullPoniterException when null is added.  Only one thread can take control over this if multiple threads want to take control over it then they have to maintain the queue that's why it is known as thread-safe.
  • 14. Thanks Stay Connected with us for more chapters on JAVA facebook.com/apex.tgi twitter.com/ApextgiNoida pinterest.com/apextgi