Wednesday, 25 February 2009

Java™ How to Program, Sixth Edition - Part19

Few weeks back i started reading Java™ How to Program, Sixth Edition By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

Nice book written By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

I wanted to share few quotations found the book from the 19th chapter.

1) The Java collections framework gives the programmer access to prepackaged data structures as well as to algorithms for manipulating them.

2) A collection is an object that can hold references to other objects. The collection interfaces declare the operations that can be performed on each type of collection.

3) The classes and interfaces of the collections framework are in package java.util.

4) Class Arrays provides static methods for manipulating arrays, including sort for sorting an array, binarySearch for searching a sorted array, equals for comparing arrays and fill for placing items in an array.

5) Arrays method asList returns a List view of an array, which enables a program to manipulate the array as if it were a List. Any modifications made through the List view change the array, and any modifications to the array change the List view.

6) Method size gets the number of items in a List, and method get returns a List element.

7) Interface Collection is the root interface in the collection hierarchy from which interfaces Set and List are derived. Interface Collection contains bulk operations for adding, clearing, comparing and retaining objects in a collection. Interface Collection provides a method iterator for getting an Iterator.

8) Class Collections provides static methods for manipulating collections. Many of the methods are implementations of polymorphic algorithms for searching, sorting and so on.

9) A List is an ordered Collection that can contain duplicate elements.

10) Interface List is implemented by classes ArrayList, LinkedList and Vector. Class ArrayList is a resizable-array implementation of a List. A LinkedList is a linked-list implementation of a List.

11) Iterator method hasNext determines whether a Collection contains another element. Method next returns a reference to the next object in the Collection and advances the Iterator.

12) Method subList returns a view of a portion of a List. Any changes made to this view are also made to the List.

13) Method clear removes elements from a List.

14) Method toArray returns the contents of a collection as an array.

15) Class Vector manages dynamically resizable arrays. At any time, a Vector contains a number of elements that is less than or equal to its capacity. If a Vector needs to grow, it grows by its capacity increment. If no capacity increment is specified, Java doubles the size of the Vector each time additional capacity is required. The default capacity is 10 elements.

16) Vector method add adds its argument to the end of the Vector. Method insertElementAt inserts an element at the specified position. Method set sets the element at a specific position.

17) Vector method remove removes the first occurrence of its argument from the Vector. Method removeAllElements removes every element from the Vector. Method removeElementAt removes the element at the specified index.

18) Vector method firstElement returns a reference to the first element. Method lastElement returns a reference to the last element.

19) Vector method contains determines whether the Vector contains the searchKey specified as an argument. Vector method indexOf gets the index of the first location of its argument. The method returns 1 if the argument is not found in the Vector.

20) Vector method isEmpty determines whether the Vector is empty. Methods size and capacity determine the number of elements currently in the Vector and the number of elements that can be stored in the Vector without allocating more memory, respectively.

21) Algorithms sort, binarySearch, reverse, shuffle, fill and copy operate on Lists. Algorithms min and max operate on Collections. Algorithm reverse reverses the elements of a List, fill sets every List element to a specified Object, and copy copies elements from one List into another List. Algorithm sort sorts the elements of a List.

22) Algorithms addAll appends all the elements in an array to a collection, frequency calculates how many elements in the collection are equal to the specified element, and disjoint determines whether two collections have elements in common.

23) Algorithms min and max find the smallest and largest items in a collection.

24) The Comparator interface provides a means of sorting a Collection's elements in an order other than their natural order.

25) Collections method reverseOrder returns a Comparator object that can be used with sort to sort elements of a collection in reverse order.

26) Algorithm shuffle randomly orders the elements of a List.

27) Algorithm binarySearch locates an Object in a sorted List.

28) Class Stack extends Vector. Stack method push adds its argument to the top of the stack. Method pop removes the top element of the stack. Method peek returns a reference to the top element without removing it. Stack method empty determines whether the stack is empty.

29) Queue, a new collection interface introduced in J2SE 5.0, extends interface Collection and provides additional operations for inserting, removing and inspecting elements in a queue.

30) PriorityQueue, one of the Queue implementations, orders elements by their natural ordering (i.e., the implementation of the compareTo method) or by a Comparator object that is supplied through the constructor.

31) The common PriorityQueue operations are offer to insert an element at the appropriate location based on priority order, poll to remove the highest-priority element of the priority queue (i.e., the head of the queue), peek to get a reference to the highest-priority element of the priority queue, clear to remove all elements in the priority queue and size to get the number of elements in the priority queue.

32) A Set is a Collection that contains no duplicate elements. HashSet stores its elements in a hash table. treeSet stores its elements in a tree.

33) Interface SortedSet extends Set and represents a set that maintains its elements in sorted order. Class TReeSet implements SortedSet.

34) TReeSet method headSet gets a view of a treeSet that is less than a specified element. Method tailSet gets a view that is greater than or equal to a specified element. Any changes made to the view are made to the TReeSet.

35) Maps map keys to values and cannot contain duplicate keys. Maps differ from Sets in that Maps contain both keys and values, whereas Sets contain only values. HashMaps store elements in a hash table, and treeMaps store elements in a tree.

36) Hashtables and HashMaps store elements in hash tables, and treeMaps store elements in trees.

37) HashMap is a generic class that takes two type arguments. The first type argument specifies the type of key, and the second type argument specifies the type of value.

38) HashMap method put adds a key and a value into a HashMap. Method get locates the value associated with the specified key. Method isEmpty determines whether the map is empty.

39) HashMap method keySet returns a set of the keys. Map methods size and isEmpty returns the number of key-value pairs in the Map and a boolean indicating whether the Map is empty, respectively.

40) Interface SortedMap extends Map and represents a map that maintains its keys in sorted order. Class treeMap implements SortedMap.

41) A Properties object is a persistent Hashtable object. Class Properties extends Hashtable.

42) The Properties no-argument constructor creates an empty Properties table with no default properties. There is also an overloaded constructor that is passed a reference to a default Properties object containing default property values.

43) Properties method setProperty specifies the value associated with the key argument. Properties method getProperty locates the value of the key specified as an argument. Method store saves the contents of the Properties object to the OutputStream object specified as the first argument. Method load restores the contents of the Properties object from the InputStream object specified as the argument.

44) Collections from the collections framework are unsynchronized. Synchronization wrappers are provided for collections that can be accessed by multiple threads.

45) The Collections API provides a set of public static methods for converting collections to unmodifiable versions. Unmodifiable wrappers throw UnsupportedOperationExceptions if attempts are made to modify the collection.

46) The collections framework provides various abstract implementations of collection interfaces from which the programmer can quickly flesh out complete customized implementations.

About the Authors

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT's Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. Paul is one of the most experienced Java corporate trainers having taught about 100 professional Java training courses. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling Computer Science textbook authors.

No comments: