New Features (Collection Framework)
As the name indicates collections is a group of objects known as its elements. Basically it is a package of data structures that includes ArrayLists, LinkedLists, HashSets, etc. A collection is simply an object that groups multiple elements into a single unit. It is also called as a container sometimes. It is used to store, retrieve, manipulate, and communicate aggregate data.
to Collections API
A collection is simply an object that groups multiple elements into a single unit. It is also called as a container sometimes. It is used to store, retrieve, manipulate, and communicate aggregate data.
and Disadvantages of collection Framework
In this section, you will read the advantages and disadvantages of Java Collection Framework.
6.0 Collection Framework
Some of the new collections APIs have been introduced in Java 6.0.
In Collection framework, we are able to improve the performance hashing function that is used by java.util.HashMap. It provides some new Collection interfaces also.
Lets See How to Work With Collections Framework With the Help of Following Examples.
In NavigableMap we use methods to return the key value pair like navMap.put(1, "January"); whereas in NavigableSet we use methods to return values.
In the example below we have used NavigableSet method to sort the elements in ascending order, descending order, also to retrieve the element which is immediately greater than or equal to 35 etc.
In this section provides you an example to HashSet collection frame work. A HashSet is a set that doesn't allow duplicate elements and doesn't order or position its elements.
This section discusses an example to demonstrate the various methods of List interface. We are using two classes ArrayList and LinkedList in the example code.
In the following example, we have used the TreeMap method, which stores its elements in a tree and orders its elements based on their values. Here in the example we have used the key of the element to show the values of the element.
In the following example, we have used the TreeSet collection, which is similar to TreeMap that stores its elements in a tree and maintain order of its elements based on their values.
Simple Java Program for beginners that prints HelloWorld! on console.