Category Archive for: java util Part 1 The Collections Framework

The Map Classes

The Map Classes Several classes provide implementations of the map interfaces. The classes that can be used for maps are summarized here: Notice that AbstractMap is a superclass rortne three cor-crete map Implementations. Weak HashMap implements a map that uses “weak keys,” which allows an clement in, a map to be garbage-collected when its key is unused. This…

Read More →

The Sorted Map Interface ,

The Sorted Map Interface , The”SortedMap interface extends Map. It ensures that the entries are maintained in ascending key order. The methods declared by SortedMap are summarized in . several methods throw a NoSuchElementException when no items are in the invoking map. A ClassCastException is thrown when an object is incompatible withthe elements in a map. A…

Read More →

The map interfaces

The map interfaces  Because the map intc·rt.lCes define of maps begins with them, The  interfaces tlr pcrt  Each interface is examined next, in turn. The Map Interlace The Map interface maps unique keys to values. A key is an object that you use to retrieve a value at a later date: Given a’ key and a value,…

Read More →

Storing user Define class in Collection

Storing user Define class in Collection  Pay special attention to how the list is displayed in reverse. After the list is modified, litr points to the end of the list. (Remember, litr.hasNext() returns false when the end of the list has been reached.) To traverse the list in reverse, the program continues to use litr, but this time…

Read More →

Accessing a Collection Via an Iterator

Accessing a Collection Via an Iterator Often, you will want to cycle through the elements in a collection. For example, you might want to display each element. By far, the easiest way to do this is to employ an iterator, an object that implements either the Iterator or the Listiterator interface. Iterator enables you to cycle through il collection,…

Read More →

The Tree Set Class

The Tree Set Class Tree Set provides an implementation of the Set interface that uses a tree-for storage.’ Objects are storminess sorted, ascending order, Access and retrieval times are quite fast, . which makes Teri Set an excellent choice when storing large amounts of sorted information that must be found quickly. The following constructors are defined: Tree Set( ) Tree…

Read More →

The Hash Set Class

The Hash Set Class Hash Set extends Abstract Set and implements the Set interface. It creates a collection the uses a hash table for storage. As most readers likely know, a hash table information by using a mechanism called hashing. In hashing, the informational content of a keyis used to determine a unique value, called its hash code.…

Read More →

The Linked List Class

The Linked List Class The Linked List class extends Abstract Sequential List and implements the List interface. It provides a linked-list data structure. It has the two constructors, shown here’: Linked List( ) , Linked List(Collection c) The first constructor builds an empty linked list. The second constructor builds a linked list that is initialized with the elements of the…

Read More →

The Collection Classes

The Collection Classes  Now that you are familiar with the collection interfaces, you arc ready to examine the standard classes that implement them. Some of the classes provide full implementations that can be used as-is. Others are abstract, providing skeletal irn plcmc atlons that I Used (‘IS starting points for creating concrete collections. None . of the collection classes…

Read More →

The Set Interface

The Set Interface . Toe Set interface defines a set. It extends Collection and declares the behavior of a collection that does noT allow duplicate clements. Therefore, the add( ) method returns false if an attempt is made to add duplicate clements Loa set. It docs not define any additional methods of its own The sortedset Interface The…

Read More →

Back to Top