SlideShare a Scribd company logo
Java.util Package
Java.util package contains the collections
framework, legacy collection classes, event
model, date and time facilities,
internationalization, and miscellaneous
utility classes.
ArrayDeque
• 1. ArrayDeque implements Deque interface
and ArrayDeque are available from jdk1.6.
2. Deque is that queue which allows insert and
remove of elements from both sides.
3. ArrayDeque is not thread safe. ArrayDeque
allows unlimited insertion of elements.
Constructor & Description
• ArrayDeque()
• This constructor is used to create an empty array
deque with an initial capacity sufficient to hold 16
elements.
• ArrayDeque(Collection<? extends E> c)
• This constructor is used to create a deque containing
the elements of the specified collection.
• ArrayDeque(int numElements)
• This constructor is used to create an empty array
deque with an initial capacity sufficient to hold the
specified number of elements.
• boolean add(E e)
• This method inserts the specified element at the end of this deque.
• void addFirst(E e)
• This method inserts the specified element at the front of this deque.
• void addLast(E e)
• This method inserts the specified element at the end of this deque.
• void clear()
• This method removes all of the elements from this deque.
• ArrayDeque<E> clone()
• This method returns a copy of this deque.
• boolean contains(Object o)
• This method returns true if this deque contains the specified element.
• The java.util.ArrayList class provides resizable-array
and implements theList interface.Following are the
important points about ArrayList:
• ArrayList class can contain duplicate elements.
• ArrayList class maintains insertion order.
• ArrayList class is non synchronized.
• ArrayList allows random access because array works at
the index basis.
• ArrayList class uses a dynamic array for storing the
elements.It extends AbstractList class and implements
List interface.
• The java.util.Arrays class contains a static factory
that allows arrays to be viewed as lists.Following
are the important points about Arrays:
• This class contains various methods for
manipulating arrays (such as sorting and
searching).
• The methods in this class throw a
NullPointerException if the specified array
reference is null.
• public class Arrays extends Object
• The java.util.BitSet class implements a vector of bits that grows as
needed.Following are the important points about BitSet:
• A BitSet is not safe for multithreaded use without external
synchronization.
• All bits in the set initially have the value false.
• Passing a null parameter to any of the methods in a BitSet will
result in a NullPointerException.
• BitSet()
• This constructor creates a new bit set.
• BitSet(int nbits)
• This constructor creates a bit set whose initial size is large enough
to explicitly represent bits with indices in the range 0 through nbits-
1.
• The java.util.calendar class is an abstract class that provides
methods for converting between a specific instant in time and a set
of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR,
and so on, and for manipulating the calendar fields, such as getting
the date of the next week.
• public abstract class Calendar extends Object implements
Serializable, Cloneable, Comparable<Calendar>
• protected Calendar()
• This constructor constructs a Calendar with the default time zone
and locale.
• protected Calendar(TimeZone zone, Locale aLocale)
• This constructor constructs a calendar with the specified time zone
and locale.
• The java.util.Dictionary class is the abstract parent of any class, such as Hashtable,
which maps keys to values.Following are the important points about Dictionary:
• java.util.Dictionary class every key and every value is an object.
• java.util.Dictionary object every key is associated with at most one value.
• public abstract class Dictionary<K,V> extends Object
• Dictionary()
• This is the single constructor.
• abstract Enumeration<V> elements()
• This method returns an enumeration of the values in this dictionary.
• abstract V get(Object key)
• This method returns the value to which the key is mapped in this dictionary.
• abstract boolean isEmpty()
• This method tests if this dictionary maps no keys to value.
• abstract Enumeration<K> keys()
• This method returns an enumeration of the keys in this dictionary.
• abstract int size()
• This method returns the number of entries (distinct keys) in this dictionary.
• etc…
• The java.util.EnumMap class is a specialized Map
implementation for use with enum keys.Following are the
important points about EnumMap:
• All of the keys in an enum map must come from a single
enum type that is specified, explicitly or implicitly, when
the map is created.
• Enum maps are maintained in the natural order of their
keys.
• EnumMap is not synchronized.If multiple threads access an
enum map concurrently, and at least one of the threads
modifies the map, it should be synchronized externally.
• public class EnumMap<K extends Enum<K>,V> extends
AbstractMap<K,V> implements Serializable, Cloneable
• EnumMap(Class<K> keyType)
• This constructor creates an empty enum map with the
HashMap in Java
• HashMap in Java with Example. HashMap maintains
key and value pairs and often denoted
as HashMap<Key, Value> or HashMap<K, V>.
• HashMap implements Map interface.
• HashMap is similar to Hashtable with two exceptions –
HashMap methods are unsynchornized and it allows
null key and null values unlike Hashtable
• A HashMap contains values based on the key. It
implements the Map interface and extends
AbstractMap class.
• It contains only unique elements.
• It may have one null key and multiple null values.
• It maintains no order.
• public class HashMap<K,V> extends AbstractMap<K,V>
• uses hashtable to store the elements.It extends AbstractSet class
and implements Set interface.
• contains unique elements only.
• Difference between List and Set:
• List can contain duplicate elements whereas Set contains unique
elements only.
• public class HashSet<E> extends AbstractSet<E> implements
Set<E>, Cloneable, Serializable
• HashSet()
• This constructs a new, empty set; the backing HashMap instance
has default initial capacity (16) and load factor (0.75).
• HashSet(Collection<? extends E> c)
• This constructs a new set containing the elements in the specified
collection.
• boolean add(E e)
• This method adds the specified element to this set if it is not
already present.
Java LinkedHashSet class
• Java LinkedHashSet class
• contains unique elements only like HashSet. It extends HashSet
class and implements Set interface.
• maintains insertion order.
• The java.util.LinkedHashSet class is a Hash table and Linked list
implementation of the Set interface, with predictable iteration
order.Following are the important points about LinkedHashSet:
• This class provides all of the optional Set operations, and permits
null elements.
• public class LinkedHashSet<E> extends HashSet<E> implements
Set<E>, Cloneable, Serializable
• LinkedHashSet()
• This constructs a new, empty linked hash set with the default initial
capacity (16) and load factor (0.75).
• LinkedHashSet(Collection<? extends E> c)
• This constructs a new linked hash set with the same elements as
the specified collection.
java.util.Properties
• The java.util.Properties class is a class which represents a
persistent set of properties.The Properties can be saved to a stream
or loaded from a stream.Following are the important points about
Properties:
• Each key and its corresponding value in the property list is a string.
• A property list can contain another property list as its 'defaults', this
second property list is searched if the property key is not found in
the original property list.
• This class is thread-safe; multiple threads can share a single
Properties object without the need for external synchronization.
• public class Properties extends Hashtable<Object,Object>
• Advantage of properties file
• Easy Maintenance: If any information is changed from the
properties file, you don't need to recompile the java class. It is
mainly used to contain variable information i.e. to be changed.
• String getProperty(String key)
• This method searches for the property with the specified key in this

More Related Content

PPTX
Collections framework in java
PPTX
Collections Training
PPTX
Java collections
ODP
Java Collections
PPT
java collections
PPTX
Java.util
PPT
Collection Framework in java
PPT
Java collection
Collections framework in java
Collections Training
Java collections
Java Collections
java collections
Java.util
Collection Framework in java
Java collection

What's hot (20)

PDF
5 collection framework
PDF
Java Collection framework
PPT
Collections in Java
PDF
Java Collections Tutorials
PPT
Java collections concept
PDF
Collections Api - Java
PPTX
Java - Collections framework
PPT
JAVA Collections frame work ppt
PDF
07 java collection
PDF
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
PPTX
Java Collections Framework Inroduction with Video Tutorial
PPT
Java Collections Framework
PDF
Collections Java e Google Collections
PDF
Collections in Java Notes
PDF
Collections In Java
DOCX
Java collections notes
PPT
Java collection
PDF
Java Collections Framework
5 collection framework
Java Collection framework
Collections in Java
Java Collections Tutorials
Java collections concept
Collections Api - Java
Java - Collections framework
JAVA Collections frame work ppt
07 java collection
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections Framework Inroduction with Video Tutorial
Java Collections Framework
Collections Java e Google Collections
Collections in Java Notes
Collections In Java
Java collections notes
Java collection
Java Collections Framework
Ad

Similar to Java util (20)

PPTX
Java Programming Comprehensive Guide.pptx
PPTX
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
PPTX
collectionsframework210616084411 (1).pptx
PPTX
collection framework.pptx
PPT
PDF
Week_2_Lec_6-10_with_watermarking_(1).pdf
PPT
12_-_Collections_Framework
PPTX
arraylist in java a comparison of the array and arraylist
PPTX
module2a it is module 2 so it is module 2.pptx
PPTX
Java Unit 2 (Part 2)
PPTX
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
PPTX
Javasession7
PPTX
Collections in java in detail for easy understanding
PPTX
Java collections
PPTX
Java 103 intro to java data structures
PPT
Md08 collection api
PPTX
Java collections
PPTX
Java Collections Framework - Interfaces, Classes and Algorithms
PPTX
Collections lecture 35 40
PPTX
JAVA(UNIT 4)
Java Programming Comprehensive Guide.pptx
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
collectionsframework210616084411 (1).pptx
collection framework.pptx
Week_2_Lec_6-10_with_watermarking_(1).pdf
12_-_Collections_Framework
arraylist in java a comparison of the array and arraylist
module2a it is module 2 so it is module 2.pptx
Java Unit 2 (Part 2)
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Javasession7
Collections in java in detail for easy understanding
Java collections
Java 103 intro to java data structures
Md08 collection api
Java collections
Java Collections Framework - Interfaces, Classes and Algorithms
Collections lecture 35 40
JAVA(UNIT 4)
Ad

More from Srikrishna k (16)

PPTX
Android
PPTX
Hsqldb tutorial
PPTX
S3inmule
PPTX
Mule sqs
PPTX
Apachepoitutorial
PPTX
Introduction testingmule
PPTX
Designpattern
PPTX
Kafka tutorial
PPTX
Test ng tutorial
PPTX
Webservices intro
PPTX
Easy mock
PPTX
Apache kafka
PPTX
Apachespark 160612140708
PPTX
Vmtransport 160723040146
PPTX
Groovydemo 160721051742
PPTX
Apache kafka
Android
Hsqldb tutorial
S3inmule
Mule sqs
Apachepoitutorial
Introduction testingmule
Designpattern
Kafka tutorial
Test ng tutorial
Webservices intro
Easy mock
Apache kafka
Apachespark 160612140708
Vmtransport 160723040146
Groovydemo 160721051742
Apache kafka

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Spectroscopy.pptx food analysis technology
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
August Patch Tuesday
PPTX
cloud_computing_Infrastucture_as_cloud_p
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25-Week II
Spectroscopy.pptx food analysis technology
Univ-Connecticut-ChatGPT-Presentaion.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Tartificialntelligence_presentation.pptx
OMC Textile Division Presentation 2021.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation theory and applications.pdf
1. Introduction to Computer Programming.pptx
A comparative analysis of optical character recognition models for extracting...
August Patch Tuesday
cloud_computing_Infrastucture_as_cloud_p

Java util

  • 1. Java.util Package Java.util package contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes.
  • 2. ArrayDeque • 1. ArrayDeque implements Deque interface and ArrayDeque are available from jdk1.6. 2. Deque is that queue which allows insert and remove of elements from both sides. 3. ArrayDeque is not thread safe. ArrayDeque allows unlimited insertion of elements.
  • 3. Constructor & Description • ArrayDeque() • This constructor is used to create an empty array deque with an initial capacity sufficient to hold 16 elements. • ArrayDeque(Collection<? extends E> c) • This constructor is used to create a deque containing the elements of the specified collection. • ArrayDeque(int numElements) • This constructor is used to create an empty array deque with an initial capacity sufficient to hold the specified number of elements.
  • 4. • boolean add(E e) • This method inserts the specified element at the end of this deque. • void addFirst(E e) • This method inserts the specified element at the front of this deque. • void addLast(E e) • This method inserts the specified element at the end of this deque. • void clear() • This method removes all of the elements from this deque. • ArrayDeque<E> clone() • This method returns a copy of this deque. • boolean contains(Object o) • This method returns true if this deque contains the specified element.
  • 5. • The java.util.ArrayList class provides resizable-array and implements theList interface.Following are the important points about ArrayList: • ArrayList class can contain duplicate elements. • ArrayList class maintains insertion order. • ArrayList class is non synchronized. • ArrayList allows random access because array works at the index basis. • ArrayList class uses a dynamic array for storing the elements.It extends AbstractList class and implements List interface.
  • 6. • The java.util.Arrays class contains a static factory that allows arrays to be viewed as lists.Following are the important points about Arrays: • This class contains various methods for manipulating arrays (such as sorting and searching). • The methods in this class throw a NullPointerException if the specified array reference is null. • public class Arrays extends Object
  • 7. • The java.util.BitSet class implements a vector of bits that grows as needed.Following are the important points about BitSet: • A BitSet is not safe for multithreaded use without external synchronization. • All bits in the set initially have the value false. • Passing a null parameter to any of the methods in a BitSet will result in a NullPointerException. • BitSet() • This constructor creates a new bit set. • BitSet(int nbits) • This constructor creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits- 1.
  • 8. • The java.util.calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. • public abstract class Calendar extends Object implements Serializable, Cloneable, Comparable<Calendar> • protected Calendar() • This constructor constructs a Calendar with the default time zone and locale. • protected Calendar(TimeZone zone, Locale aLocale) • This constructor constructs a calendar with the specified time zone and locale.
  • 9. • The java.util.Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values.Following are the important points about Dictionary: • java.util.Dictionary class every key and every value is an object. • java.util.Dictionary object every key is associated with at most one value. • public abstract class Dictionary<K,V> extends Object • Dictionary() • This is the single constructor. • abstract Enumeration<V> elements() • This method returns an enumeration of the values in this dictionary. • abstract V get(Object key) • This method returns the value to which the key is mapped in this dictionary. • abstract boolean isEmpty() • This method tests if this dictionary maps no keys to value. • abstract Enumeration<K> keys() • This method returns an enumeration of the keys in this dictionary. • abstract int size() • This method returns the number of entries (distinct keys) in this dictionary. • etc…
  • 10. • The java.util.EnumMap class is a specialized Map implementation for use with enum keys.Following are the important points about EnumMap: • All of the keys in an enum map must come from a single enum type that is specified, explicitly or implicitly, when the map is created. • Enum maps are maintained in the natural order of their keys. • EnumMap is not synchronized.If multiple threads access an enum map concurrently, and at least one of the threads modifies the map, it should be synchronized externally. • public class EnumMap<K extends Enum<K>,V> extends AbstractMap<K,V> implements Serializable, Cloneable • EnumMap(Class<K> keyType) • This constructor creates an empty enum map with the
  • 11. HashMap in Java • HashMap in Java with Example. HashMap maintains key and value pairs and often denoted as HashMap<Key, Value> or HashMap<K, V>. • HashMap implements Map interface. • HashMap is similar to Hashtable with two exceptions – HashMap methods are unsynchornized and it allows null key and null values unlike Hashtable • A HashMap contains values based on the key. It implements the Map interface and extends AbstractMap class. • It contains only unique elements. • It may have one null key and multiple null values. • It maintains no order. • public class HashMap<K,V> extends AbstractMap<K,V>
  • 12. • uses hashtable to store the elements.It extends AbstractSet class and implements Set interface. • contains unique elements only. • Difference between List and Set: • List can contain duplicate elements whereas Set contains unique elements only. • public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable • HashSet() • This constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75). • HashSet(Collection<? extends E> c) • This constructs a new set containing the elements in the specified collection. • boolean add(E e) • This method adds the specified element to this set if it is not already present.
  • 13. Java LinkedHashSet class • Java LinkedHashSet class • contains unique elements only like HashSet. It extends HashSet class and implements Set interface. • maintains insertion order. • The java.util.LinkedHashSet class is a Hash table and Linked list implementation of the Set interface, with predictable iteration order.Following are the important points about LinkedHashSet: • This class provides all of the optional Set operations, and permits null elements. • public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, Serializable • LinkedHashSet() • This constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75). • LinkedHashSet(Collection<? extends E> c) • This constructs a new linked hash set with the same elements as the specified collection.
  • 14. java.util.Properties • The java.util.Properties class is a class which represents a persistent set of properties.The Properties can be saved to a stream or loaded from a stream.Following are the important points about Properties: • Each key and its corresponding value in the property list is a string. • A property list can contain another property list as its 'defaults', this second property list is searched if the property key is not found in the original property list. • This class is thread-safe; multiple threads can share a single Properties object without the need for external synchronization. • public class Properties extends Hashtable<Object,Object> • Advantage of properties file • Easy Maintenance: If any information is changed from the properties file, you don't need to recompile the java class. It is mainly used to contain variable information i.e. to be changed. • String getProperty(String key) • This method searches for the property with the specified key in this