Tutorials

Java Collection Framework


Collections class


Java Collections class provides lots of static methods which can operate on collections or can return collections.

Collections class and Collection interface are two separate concepts.

 

Generally, beginners misunderstand both as one but it’s not wise to do so. In this chapter we will read in detail about Collections class in java.

 

In java Collection framework, Collections is a class which extends Object class.

 

Important points on Collection class

  • Collections is a class and is totally different from Collections interface.
  • Both Collections class and Collection interface is a part of Collection framework.
  • Collections class provide various static methods like SynchronizedList(), sort(), max(), min(), etc. to help develop application efficiently.
  • If you provide a null Collections or null class objects to any methods of Collections class then it throws a NullPointerException.

Declaration of Collections class


public class Collections extends Object

Important Collections class methods

 

 

 

Example 1: addAll() 

 

Example 2: binarySearch()

Click here to see example

 

Example 3: reverse()  

 

Example 4: max() 

 

Example 5: min() 

 

 



Please Share this page
Views : 64
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!