Java-Part 9

Java-Part 8 Index   Java-Part 10

*ResourceBundle, ListResourceBundle, PropertyResourceBundle classes aid in the Internalization(I18N) of large programs.

*PropertyPermission which allows you to grant a read/write permission to a system property.

*The java collection framework standardizes the way in which groups of objects are handled by your programs.

* Algorithms operate on collections and are defined as static methods within the “Collection” class.

*Although “maps” are not the collections, but they are truly integrated with the collections.

*Collection[I]=> This is the foundation upon which the collection framework is built.

*List[I]=>It extends Collection, it stores the sequence of elements. Elements can be inserted or accessed by their position in the list using zero(0) based index. A list may contain duplicate elements.

*Set[I]=>It extends Collection, it doesn’t allow duplicates.

*SortedSet[I]=>It extends Set & declares the set sorted in ascending order

*Iterator[I]=> when we want to use we have to follow the following steps.

  • Setup loop that makes a call to “hasNext()“.
  • Within the loop use “next()”.

*RandomAccess[I] => It contains no members, It is implemented by “ArrayList” legacy “Vector” class.

* ArrayList[C]=> It is a dynamic array that can grow as needed. You can call ensureCapacity() method to increase the capacity of ArrayList manually.

*LinkedList[C] => It provides a linked list data structure.

*HasSet[C]=> It creates the collection that uses a hash table for storage. The hashcode() is then used as the index at which the data associated with the key stored. The default fill ratio is 7.5.  It doesn’t guarantee the order of its elements.

*LinkedHashSet[C]=> It maintains the linked list of entries in the set, in order in which they were inserted.

*TreeSet[C]=> Objects are stored in ascending order.

*Map[I]=>Map is an object that stores association between key & values. Both key & values are objects. “NULL” is not allowed in the Map. Collection views are the means by which maps are integrated in to the collection framework.

*To do we “keySet()”                                                                                                                                                  “entrySet()” =>It returns objects type “Map.Entry”

*SortedMap[I] =>It allows very efficient manipulations of sub maps.

*Map.Entry[I]=> This is an inner class for Map.

*AbstractMap is the super class for all concrete implementations of Map.

*WeakHashMap implements the map that uses weak keys which allows an element in a map to be garbage collected when its key is unused.

*HashMap[C] => It uses HashTable to implement Map interface.

*TreeMap[C] => Elements will be stored in ascending key order

*LinkedHashMap[C] => It maintains the linked list of entries in the Map.

*IdentityHashMap[C] =>It is similar to the HashMap except it uses reference equality when comparing elements.

*Collection Algorithms => The collection framework defines several algorithms that can be applied to collections & maps. The algorithms are defined as static methods within the Collection class. None of the collection implementations are synchronized. In order to use we have to use synchronized methods. It defines the following static variables.

EMPTY_SET, EMPTY_LIST, EMPTY_MAP.

*Arrays =>It is not part of collections, the fill the gap between arrays & collections.

*Legacy Classes & Interfaces => None of the collections classes are synchronized, but all legacy classes are synchronized.

  1. Enumeration[I]
  2. Vector[C] => it is similar to the ArrayList
  3. Stack[C]=>It is a sub class of vector that implements a standard last-in-first out stack.
  4. Dictionary[C]
  5. HashTable[C] => Similar to HashMap but is synchronized. HashTable can only stores the elements that override the “hashcode() & equals()”. It doesn’t supports iterators directly.
  6. Properties[C]=> It is the sub class of HashTable. This class is used by many other classes. Both key & values are Strings. One of the most useful aspects of Properties is that the information contained in a Properties object can be easily stored to or loaded from disk.

*StringTokenizer[C] => Parsing is the division of text into a set of discrete parts or tokens, which in a certain sequence can convey a semantic meaning. It is often called as lexer/scanner. It implements the Enumeration interface.

*BitSet[C] => A BitSet class creates a special type of array that holds bit values. It is similar to Vector of bits. All bits are initialized to zero. BitSet implements “Clonable” interface.

*Date[C] => It encapsulates current date & time. It counts from midnight Jan 1, 1970. After Java 2, it implements Comparable interface.  By using this we can’t get the individual values. Date comparison can be done in 3 ways.

  1. Using “getTime()”
  2. Using methods “before(), after(), equals()”
  3. Using “comapreTo()”

*Calendar[C] => The abstract class provides a set of methods that allows you convert a time in milli seconds to number of useful components.

*GegorgianCalendar[C]=>

*TimeZone[C] =>It allows you to work with time zone offsets from GMT

*SimpleTimeZone[C] =>It also computes day light saving time.

*Locale[C] => The Locale class is instantiated to produce objects that each describe geographical or cultural region. It provides to write I18N programs.

*Random[C] => It is the generator of pseudo random numbers.

*Observable[C] => Observable class is used to create sub classes that other parts of your program can observe.

*Currency[C] => This class encapsulates the information regarding Currency.

*A stream is linked to a physical device by the Java I/O system.

*File[C] => File class doesn’t specify how information is retrieved from or stored in files. File supports Comparable interface.

*FileNameFilter[C] => By using this we can limit the number of files returned. It defines only a single method “accept()

*Serialization => Is the process of writing the state of an object to a byte stream. It is needed to implement the RMI. Only an object that implements the Serializable interface can be saved & restored by the serialization facilities. Variables that are declared as transient are not saved by the serialization facilities. static values are also not saved.

*Collections in One Shot=>

collections
Java-Part 8 Index   Java-Part 10

2 thoughts on “Java-Part 9

Leave a comment