The Queue interface extends the Collection interface and is present in java.util package is used to hold the elements about to be processed in FIFO (First In First Out) order. It is an ordered list of objects that can only be used to insert elements at the end of the list and delete elements from […]
September 16, 2022 | Java | No comments
The Comparable interface is used to compare an object of the same class with an instance of that class; it also enables data ordering for user-defined class objects. The class has to implement the java.lang.Comparable interface to compare its instance, it provides the compareTo() method, which accepts an object of that class as an argument. Its sorting algorithm is determined by the type of object used by the interface. If the object type is a string, it is sorted lexicographically. Else, If the object type is a wrapper class object, such as an integer […]
August 5, 2022 | Java | No comments
The Collections class belongs to the Java Collections Framework. The package java.util.Collections is the package containing the Collections class. The Collections class mainly uses static methods that operate on or return collections. If the collection or object supplied to the methods is null, all the methods in this class throw the NullPointerException. Declaration: Collections Methods: […]
August 5, 2022 | Java | No comments