Published on September 13, 2016
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
Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a ...
Java.util package tutorial - Learning Java.util Packages in simple and easy steps : A beginner's tutorial containing complete knowledge of all the classes, interfaces ...
The java.util package contains classes that deal with collections, events, date and time, internationalization and various helpful utilities.
Home Maven Download: Welcome to the Java UTIL project site. This is the central place for general information about the project itself, the different libraries that ...
java.util; java.util / AbstractList 1: AbstractMap 1: AbstractSet 2: ArrayDeque 1: ArrayList 27: Arrays 43: BitSet 10: Calendar 32: Collection 1: Collections 36 ...
Introduction. The java.util.ArrayList class provides resizable-array and implements the List interface.Following are the important points about ArrayList:
Home » openjdk-7 » java » util » java.util. Contains the collections framework, legacy collection classes, event model, date and time facilities ...
java-util - Rarely available and hard-to-write Java utilities, written correctly, and thoroughly tested
java.util Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility ...
Oracle Technology Network is the ultimate, complete, and authoritative source of technical information and learning about Java.