Java Collections reverseOrder() MethodThe reverseOrder() is a Java Collections class method which returns a comparator that imposes the reverse of the natural ordering on the objects. There is two different types of Java reverseOrder() method which can be differentiated depending on its parameter. These are:
Java Collections reverseOrder() MethodThe reverseOrder() method of Java Collections class is used to get the comparator that imposes the reverse of the natural ordering on a collection of objects which implement the Comparable interface. Java Collections reverseOrder(comp) MethodThe reverseOrder() method of Java Collections class is used to get the comparator that imposes the reverse ordering of the specified comparator. SyntaxFollowing is the declaration of reverseOrder() method: Parameter
Returns
ExceptionsNA Compatibility VersionJava 1.5 and above Example 1Test it NowOutput: List sorted in ReverseOrder: [90, 50, 10, -15, -20] Example 2Test it NowOutput: List sorted in ReverseOrder: [Ruby, Python, Java, COBOL] Example 3Test it NowOutput: [Ruby, Commit, Pratham, Jaya] Example 4Test it NowOutput: List sorted in ReverseOrder: 120 50 -20 -80 Next TopicJava Collections Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India