static CloneExample1 b;
static int z = 10;
public static void main(String args)
Object o = a.clone();
b = (CloneExample1)o;
}int met1(int q)
z = q;
The Collection API is nothing but a set of data structures in Java. There are standard interfaces and implementation class and all the collections vary according to
a) the storage mechanism used
b) in the way they can access data and
c) in the rules about what the date might be stored.
The general interface java.util.Collection defines the basic framework for all collections. This interface has methods that add item into the collection, remove items from the collection, determine whether the items are in the collection and count the number of items in the collection.
A collection in which the condition is that it cannot contain the same value more than once, it is known as a Set. A Set has no special order but rejects duplicates.
The final type of specialized behavior directly supported by the Collection API is known as a Map. In a Map, it uses the set of key values to look up or index the stored date.
Hashtable / HashMap : Both use Hashing mechanism of storage. Hashtable was present right from the beginning in the JDK, but HashMap was introduced in JDK 1.2.
TreeMap: This class provides an ordered Map. The elements must be orderable, either by implementing the Comparable interface or by providing a Comparator class to perform comparisons.
This provides a compare method, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such as TreeSet or TreeMap).
This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method.
This action might not be possible to undo. Are you sure you want to continue?