Skip to content

Tag Archives: Java-Collections-Class

The size() and isEmpty() of java.util.Collection interface is used to check the size of collections and if the Collection is empty or not. isEmpty() method… Read More
Given a stream containing some elements, the task is to find the duplicate elements in this stream in Java. Examples: Input: Stream = {5, 13,… Read More
java.util.Collections.disjoint() method is present in java.util.Collections class. It is used to check whether two specified collections are disjoint or not. More formally, two collections are… Read More
java.util.Collections.frequency() method is present in java.util.Collections class. It is used to get the frequency of a element present in the specified list of Collection. More… Read More
java.util.Collections.rotate() method is present in java.util.Collections class. It is used to rotate the elements present in the specified list of Collection by a given distance.… Read More
The method is a java.util.Collections class method. It counts the frequency of the specified element in the given list. It override the equals() method to… Read More
java.util.Collections.singleton() method is a java.util.Collections class method. It creates a immutable set over a single specified element. An application of this method is to remove… Read More
java.util.Collections.reverseOrder() method is a java.util.Collections class method.   // Returns a comparator that imposes the reverse of // the natural ordering on a collection of objects… Read More
java.util.Collections.shuffle() is a java.util.Collections class method. // Shuffles mylist public static void shuffle(List mylist) This method throws UnsupportedOperationException if the given list or its list-iterator… Read More
java.util.Collections.swap() method is a java.util.Collections class method. It swaps elements at the specified positions in given list. // Swaps elements at positions "i" and "j"… Read More
java.util.Collections.reverse() method is a java.util.Collections class method. It reverses the order of elements in a list passed as an argument. // Reverses elements of myList… Read More
java.util.Collections.binarySearch() method is a java.util.Collections class method that returns position of an object in a sorted list.  // Returns index of key in sorted list… Read More
java.util.Collections.sort() method is present in java.util.Collections class. It is used to sort the elements present in the specified list of Collection in ascending order. It… Read More