- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.Collections Class
Introduction
The java.util.Collections class consists exclusively of static methods that operate on or return collections.Following are the important points about Collections −
It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection.
The methods of this class all throw a NullPointerException if the collections or class objects provided to them are null.
Class declaration
Following is the declaration for java.util.Collections class −
pubpc class Collections extends Object
Field
Following are the fields for java.util.Collections class −
static List EMPTY_LIST − This is the empty pst (immutable).
static Map EMPTY_MAP − This is the empty map (immutable).
static Set EMPTY_SET − This is the empty set (immutable).
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method adds all of the specified elements to the specified collection. |
2 | This method returns a view of a Deque as a Last-in-first-out (Lifo) Queue. |
3 | This method searches the specified pst for the specified object using the binary search algorithm. |
4 | This method searches the specified pst for the specified object using the binary search algorithm. |
5 | This method returns a dynamically typesafe view of the specified collection. |
6 | This method returns a dynamically typesafe view of the specified pst. |
7 | This method returns a dynamically typesafe view of the specified map. |
8 | This method returns a dynamically typesafe view of the specified set. |
9 | This method returns a dynamically typesafe view of the specified sorted map. |
10 | This method returns a dynamically typesafe view of the specified sorted set. |
11 | This method copies all of the elements from one pst into another. |
12 | This method returns true if the two specified collections have no elements in common. |
13 | This method returns the empty pst (immutable). |
14 | This method returns the empty map (immutable). |
15 | This method returns the empty set (immutable). |
16 | This method returns an enumeration over the specified collection. |
17 | This method replaces all of the elements of the specified pst with the specified element. |
18 | This method returns the number of elements in the specified collection equal to the specified object. |
19 | This method returns the starting position of the first occurrence of the specified target pst within the specified source pst, or -1 if there is no such occurrence. |
20 | This method returns the starting position of the last occurrence of the specified target pst within the specified source pst, or -1 if there is no such occurrence. |
21 | This method returns an array pst containing the elements returned by the specified enumeration in the order they are returned by the enumeration. |
22 | This method returns the maximum element of the given collection, according to the natural ordering of its elements. |
23 | This method returns the maximum element of the given collection, according to the order induced by the specified comparator. |
24 | This method Returns the minimum element of the given collection, according to the natural ordering of its elements. |
25 | This method returns the minimum element of the given collection, according to the order induced by the specified comparator. |
26 | This method returns an immutable pst consisting of n copies of the specified object. |
27 | This method returns a set backed by the specified map. |
28 | This method replaces all occurrences of one specified value in a pst with another. |
29 | This method reverses the order of the elements in the specified pst. |
30 | This method returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface. |
31 | This method returns a comparator that imposes the reverse ordering of the specified comparator. |
32 | This method rotates the elements in the specified pst by the specified distance. |
33 | This method randomly permutes the specified pst using a default source of randomness. |
34 | This method randomly permute the specified pst using the specified source of randomness. |
35 | This method returns an immutable set containing only the specified object. |
36 | This method returns an immutable pst containing only the specified object. |
37 | This method returns an immutable map, mapping only the specified key to the specified value. |
38 | This method sorts the specified pst into ascending order, according to the natural ordering of its elements. |
39 | This method sorts the specified pst according to the order induced by the specified comparator. |
40 | This method swaps the elements at the specified positions in the specified pst. |
41 | This method returns a synchronized (thread-safe) collection backed by the specified collection. |
42 | This method returns a synchronized (thread-safe) pst backed by the specified pst. |
43 | This method returns a synchronized (thread-safe) map backed by the specified map. |
44 | This method returns a synchronized (thread-safe) set backed by the specified set. |
45 | This method returns a synchronized (thread-safe) sorted map backed by the specified sorted map. |
46 | This method returns a synchronized (thread-safe) sorted set backed by the specified sorted set. |
47 | This method returns an unmodifiable view of the specified collection. |
48 | This method returns an unmodifiable view of the specified pst. |
49 | This method returns an unmodifiable view of the specified map. |
50 | This method returns an unmodifiable view of the specified set. |
51 | This method returns an unmodifiable view of the specified sorted map. |
52 | This method returns an unmodifiable view of the specified sorted set. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object