The Java Collections Framework (JCF) is made for handling a series of data. Storing, managing such data depends on the purpose of every interfaces and classes of the JCF. Also, there are interfaces and classes aiming directly for managing and processing the other parts of the JCF.
JCF is derivated directly from Object.
FIGURE OF JAVA COLLECTIONS FRAMEWORK STRUCTURE:
Collection is a root interface of List, Set and Queue classes.
Contains methods for all implementing classes. These methods are optimized.
Elements of every collection type can be accessed via Iterator.
For manipulating data stored in a collection, use streams.
FIGURE OF COLLECTION STRUCTURE:
Sorting means giving the elements a new order. Available with the sort() method.
Java Collection.sort() method:
uses Merge Sort for higher amount of data (needs more data to work efficiently)
uses simpler algorithms for fewer data
this behaviour can change when the element class has unique compareTo() method, or for sorting unique Comparator is used
The "Merge Sort Algorithm" is based upon the "Divide and Conquer Algorithm": a problem is divided into multiple sub-problems. Each sub-problem is solved individually. Finally, sub-problems are combined to form the final solution.
Sorting always create natural (ascending) order unless a Comparator is not used to customize the element comparing process.
EXAMPLE FOR SORTING WRAPPER TYPE:
EXAMPLE FOR SORTING CUSTOM CLASS TYPE:
Shuffling means giving the elements a randomized order. Opposite of sorting, destroys any order in the collection.
Available with shuffle() method.
EXAMPLE FOR SHUFFLING:
Routine data manipulation means several methods which are meant to manipulate collection data.
EXAMPLE FOR ROUTINE DATA MANIPULATION:
The binarySearch() method searches for position of the specified element.
The collection should be sorted before executing.
EXAMPLE FOR BINARY SEARCH:
The frequency() method returns the count of the number of times an element is present in the collection.
The disjoint() method checks if two collections contain some common element.
EXAMPLE FOR COMPOSITION METHODS:
Determining of minimum and maximum values of the collection via using min() and max() methods.
EXAMPLE FOR MIN() AND MAX() METHODS: